Skip to content

Commit

Permalink
修复ChatGPT api_base_url错误;用户可以在model_config在线模型配置中覆盖默认的api_base_url (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
liunux4odoo committed Sep 15, 2023
1 parent 80375e1 commit 955b0bc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions configs/model_config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
2 changes: 1 addition & 1 deletion server/chat/openai_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion server/chat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 955b0bc

Please sign in to comment.