Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
·
cad6136
1
Parent(s):
f650935
完善OPENAI_API_BASE设置
Browse files- config_example.json +2 -0
- modules/config.py +2 -2
- modules/shared.py +0 -2
config_example.json
CHANGED
@@ -10,6 +10,8 @@
|
|
10 |
"minimax_api_key": "",
|
11 |
"minimax_group_id": "",
|
12 |
"language": "auto",
|
|
|
|
|
13 |
// 如果使用代理,请取消注释下面的两行,并替换代理URL
|
14 |
// "https_proxy": "http://127.0.0.1:1079",
|
15 |
// "http_proxy": "http://127.0.0.1:1079",
|
|
|
10 |
"minimax_api_key": "",
|
11 |
"minimax_group_id": "",
|
12 |
"language": "auto",
|
13 |
+
// 支持自定义OpenAI API Base
|
14 |
+
// "openai_api_base": "https://api.openai.com",
|
15 |
// 如果使用代理,请取消注释下面的两行,并替换代理URL
|
16 |
// "https_proxy": "http://127.0.0.1:1079",
|
17 |
// "http_proxy": "http://127.0.0.1:1079",
|
modules/config.py
CHANGED
@@ -104,8 +104,8 @@ auth_list = config.get("users", []) # 实际上是使用者的列表
|
|
104 |
authflag = len(auth_list) > 0 # 是否开启认证的状态值,改为判断auth_list长度
|
105 |
|
106 |
# 处理自定义的api_host,优先读环境变量的配置,如果存在则自动装配
|
107 |
-
api_host = os.environ.get("
|
108 |
-
if api_host:
|
109 |
shared.state.set_api_host(api_host)
|
110 |
|
111 |
default_chuanhu_assistant_model = config.get("default_chuanhu_assistant_model", "gpt-3.5-turbo")
|
|
|
104 |
authflag = len(auth_list) > 0 # 是否开启认证的状态值,改为判断auth_list长度
|
105 |
|
106 |
# 处理自定义的api_host,优先读环境变量的配置,如果存在则自动装配
|
107 |
+
api_host = os.environ.get("OPENAI_API_BASE", config.get("openai_api_base", None))
|
108 |
+
if api_host is not None:
|
109 |
shared.state.set_api_host(api_host)
|
110 |
|
111 |
default_chuanhu_assistant_model = config.get("default_chuanhu_assistant_model", "gpt-3.5-turbo")
|
modules/shared.py
CHANGED
@@ -57,5 +57,3 @@ class State:
|
|
57 |
|
58 |
|
59 |
state = State()
|
60 |
-
if (host:=os.environ.get("OPENAI_API_BASE", None)) is not None:
|
61 |
-
state.set_api_host(host)
|
|
|
57 |
|
58 |
|
59 |
state = State()
|
|
|
|