Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
·
14c4abc
1
Parent(s):
e27bc62
bugfix: 修复使用自定义 API Base 时,embedding 出错的问题 #805
Browse files- modules/config.py +4 -0
modules/config.py
CHANGED
@@ -82,6 +82,8 @@ if os.environ.get("dockerrun") == "yes":
|
|
82 |
## 处理 api-key 以及 允许的用户列表
|
83 |
my_api_key = config.get("openai_api_key", "")
|
84 |
my_api_key = os.environ.get("OPENAI_API_KEY", my_api_key)
|
|
|
|
|
85 |
|
86 |
google_palm_api_key = config.get("google_palm_api_key", "")
|
87 |
google_palm_api_key = os.environ.get("GOOGLE_PALM_API_KEY", google_palm_api_key)
|
@@ -114,6 +116,8 @@ authflag = len(auth_list) > 0 # 是否开启认证的状态值,改为判断au
|
|
114 |
api_host = os.environ.get("OPENAI_API_BASE", config.get("openai_api_base", None))
|
115 |
if api_host is not None:
|
116 |
shared.state.set_api_host(api_host)
|
|
|
|
|
117 |
|
118 |
default_chuanhu_assistant_model = config.get("default_chuanhu_assistant_model", "gpt-3.5-turbo")
|
119 |
for x in ["GOOGLE_CSE_ID", "GOOGLE_API_KEY", "WOLFRAM_ALPHA_APPID", "SERPAPI_API_KEY"]:
|
|
|
82 |
## 处理 api-key 以及 允许的用户列表
|
83 |
my_api_key = config.get("openai_api_key", "")
|
84 |
my_api_key = os.environ.get("OPENAI_API_KEY", my_api_key)
|
85 |
+
os.environ["OPENAI_API_KEY"] = my_api_key
|
86 |
+
os.environ["OPENAI_EMBEDDING_API_KEY"] = my_api_key
|
87 |
|
88 |
google_palm_api_key = config.get("google_palm_api_key", "")
|
89 |
google_palm_api_key = os.environ.get("GOOGLE_PALM_API_KEY", google_palm_api_key)
|
|
|
116 |
api_host = os.environ.get("OPENAI_API_BASE", config.get("openai_api_base", None))
|
117 |
if api_host is not None:
|
118 |
shared.state.set_api_host(api_host)
|
119 |
+
os.environ["OPENAI_API_BASE"] = f"{api_host}/v1"
|
120 |
+
logging.info(f"OpenAI API Base set to: {os.environ['OPENAI_API_BASE']}")
|
121 |
|
122 |
default_chuanhu_assistant_model = config.get("default_chuanhu_assistant_model", "gpt-3.5-turbo")
|
123 |
for x in ["GOOGLE_CSE_ID", "GOOGLE_API_KEY", "WOLFRAM_ALPHA_APPID", "SERPAPI_API_KEY"]:
|