From 955b0bc211fb41ec9d8c1b71f5393ae6679c793d Mon Sep 17 00:00:00 2001 From: liunux4odoo <41217877+liunux4odoo@users.noreply.github.com> Date: Fri, 15 Sep 2023 22:56:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DChatGPT=20api=5Fbase=5Furl?= =?UTF-8?q?=E9=94=99=E8=AF=AF=EF=BC=9B=E7=94=A8=E6=88=B7=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E5=9C=A8model=5Fconfig=E5=9C=A8=E7=BA=BF=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=AD=E8=A6=86=E7=9B=96=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E7=9A=84api=5Fbase=5Furl=20(#1496)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configs/model_config.py.example | 1 + server/chat/openai_chat.py | 2 +- server/chat/utils.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/configs/model_config.py.example b/configs/model_config.py.example index 728cddd..e377d9d 100644 --- a/configs/model_config.py.example +++ b/configs/model_config.py.example @@ -80,6 +80,7 @@ ONLINE_LLM_MODEL = { # 需要添加代理访问(正常开的代理软件可能会拦截不上)需要设置配置openai_proxy 或者 使用环境遍历OPENAI_PROXY 进行设置 # 比如: "openai_proxy": 'http://127.0.0.1:4780' "gpt-3.5-turbo": { + "api_base_url": "https://api.openai.com/v1", "api_key": "your OPENAI_API_KEY", "openai_proxy": "your OPENAI_PROXY", }, diff --git a/server/chat/openai_chat.py b/server/chat/openai_chat.py index a7d14c9..4a46ddd 100644 --- a/server/chat/openai_chat.py +++ b/server/chat/openai_chat.py @@ -27,7 +27,7 @@ async def openai_chat(msg: OpenAiChatMsgIn): config = get_model_worker_config(msg.model) openai.api_key = config.get("api_key", "EMPTY") print(f"{openai.api_key=}") - openai.api_base = fschat_openai_api_address() + openai.api_base = config.get("api_base_url", fschat_openai_api_address()) print(f"{openai.api_base=}") print(msg) diff --git a/server/chat/utils.py b/server/chat/utils.py index 0d2e877..0c32969 100644 --- a/server/chat/utils.py +++ b/server/chat/utils.py @@ -18,7 +18,7 @@ def get_ChatOpenAI( verbose=True, callbacks=callbacks, openai_api_key=config.get("api_key", "EMPTY"), - openai_api_base=fschat_openai_api_address(), + openai_api_base=config.get("api_base_url", fschat_openai_api_address()), model_name=model_name, temperature=temperature, openai_proxy=config.get("openai_proxy")