Open Undertone0809 opened 1 year ago
maybe can use yaml to config
Yaml is a better choose in a project, but not in a script. I think we can change to the following style.
class PneConfig:
param1 = "value1"
param2 = "value3"
param3 = "value3"
@classmethod
def get_param4(cls):
....
Class attribution and class method is better than a single class in some cases. What do you think? @ruanrongman
Many instance parameters of
prompt.config.Config
can be change to class method. Using class method obtain more optimized code experience.class Config(metaclass=Singleton): def init(self): logger.info(f"[pne config] Config initialization") self.enable_cache: bool = True self._proxy_mode: str = PROXY_MODE[0] self._proxies: Optional[dict] = None self.openai_chat_api_url = "https://api.openai.com/v1/chat/completions" self.openai_completion_api_url = "https://api.openai.com/v1/completions" self.openai_proxy_url = "https://chatgpt-api.shn.hk/v1/" # FREE API self.ernie_bot_url = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions" self.ernie_bot_turbo_url = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant" self.ernie_bot_token = "https://aip.baidubce.com/oauth/2.0/token" self.key_default_retry_times = 5 """If llm(like OpenAI) unable to obtain data, retry request until the data is obtained.""" self.enable_stdout_hook = True ernie_token_pool: ErnieTokenPool = ErnieTokenPool() ernie_token_pool.start(self.get_ernie_api_key, self.get_ernie_api_secret)