From 37454db3ec95d185b4359033f75827017d09fd96 Mon Sep 17 00:00:00 2001 From: zqt <1178747941@qq.com> Date: Thu, 24 Aug 2023 13:51:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0chatgpt=20=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=90=86=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configs/model_config.py.example | 7 ++++++- server/chat/chat.py | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) 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(