diff --git a/configs/model_config.py.example b/configs/model_config.py.example index 49c4c52..4c7010e 100644 --- a/configs/model_config.py.example +++ b/configs/model_config.py.example @@ -75,10 +75,15 @@ llm_model_dict = { # urllib3.exceptions.NewConnectionError: : # Failed to establish a new connection: [WinError 10060] # 则是因为内地和香港的IP都被OPENAI封了,需要切换为日本、新加坡等地 + + # 如果出现WARNING: Retrying langchain.chat_models.openai.acompletion_with_retry.._completion_with_retry in + # 4.0 seconds as it raised APIConnectionError: Error communicating with OpenAI. + # 需要添加代理访问(正常开的代理软件可能会拦截不上)需要设置配置openai_proxy 或者 使用环境遍历OPENAI_PROXY 进行设置 "gpt-3.5-turbo": { "local_model_path": "gpt-3.5-turbo", "api_base_url": "https://api.openai.com/v1", - "api_key": os.environ.get("OPENAI_API_KEY") + "api_key": os.environ.get("OPENAI_API_KEY"), + "openai_proxy": os.environ.get("OPENAI_PROXY") }, } diff --git a/server/chat/chat.py b/server/chat/chat.py index 2bc21db..3748591 100644 --- a/server/chat/chat.py +++ b/server/chat/chat.py @@ -34,7 +34,8 @@ def chat(query: str = Body(..., description="用户输入", examples=["恼羞成 callbacks=[callback], openai_api_key=llm_model_dict[LLM_MODEL]["api_key"], openai_api_base=llm_model_dict[LLM_MODEL]["api_base_url"], - model_name=LLM_MODEL + model_name=LLM_MODEL, + openai_proxy=llm_model_dict[LLM_MODEL].get("openai_proxy") ) chat_prompt = ChatPromptTemplate.from_messages(