Spaces:
Sleeping
Sleeping
调整openai_api_base的使用,改为可以支持cloudflare的ai gateway
Browse files- locale/extract_locale.py +1 -1
- modules/config.py +1 -1
- modules/shared.py +2 -2
locale/extract_locale.py
CHANGED
@@ -7,7 +7,7 @@ asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
|
|
7 |
with open("config.json", "r", encoding="utf-8") as f:
|
8 |
config = commentjson.load(f)
|
9 |
api_key = config["openai_api_key"]
|
10 |
-
url = config["openai_api_base"] + "/
|
11 |
|
12 |
|
13 |
def get_current_strings():
|
|
|
7 |
with open("config.json", "r", encoding="utf-8") as f:
|
8 |
config = commentjson.load(f)
|
9 |
api_key = config["openai_api_key"]
|
10 |
+
url = config["openai_api_base"] + "/chat/completions" if "openai_api_base" in config else "https://api.openai.com/v1/chat/completions"
|
11 |
|
12 |
|
13 |
def get_current_strings():
|
modules/config.py
CHANGED
@@ -166,7 +166,7 @@ api_host = os.environ.get(
|
|
166 |
"OPENAI_API_BASE", config.get("openai_api_base", None))
|
167 |
if api_host is not None:
|
168 |
shared.state.set_api_host(api_host)
|
169 |
-
os.environ["OPENAI_API_BASE"] = f"{api_host}
|
170 |
logging.info(f"OpenAI API Base set to: {os.environ['OPENAI_API_BASE']}")
|
171 |
|
172 |
default_chuanhu_assistant_model = config.get(
|
|
|
166 |
"OPENAI_API_BASE", config.get("openai_api_base", None))
|
167 |
if api_host is not None:
|
168 |
shared.state.set_api_host(api_host)
|
169 |
+
os.environ["OPENAI_API_BASE"] = f"{api_host}"
|
170 |
logging.info(f"OpenAI API Base set to: {os.environ['OPENAI_API_BASE']}")
|
171 |
|
172 |
default_chuanhu_assistant_model = config.get(
|
modules/shared.py
CHANGED
@@ -23,8 +23,8 @@ class State:
|
|
23 |
api_host = f"https://{api_host}"
|
24 |
if api_host.endswith("/v1"):
|
25 |
api_host = api_host[:-3]
|
26 |
-
self.chat_completion_url = f"{api_host}/
|
27 |
-
self.openai_api_base = f"{api_host}
|
28 |
self.balance_api_url = f"{api_host}/dashboard/billing/credit_grants"
|
29 |
self.usage_api_url = f"{api_host}/dashboard/billing/usage"
|
30 |
os.environ["OPENAI_API_BASE"] = api_host
|
|
|
23 |
api_host = f"https://{api_host}"
|
24 |
if api_host.endswith("/v1"):
|
25 |
api_host = api_host[:-3]
|
26 |
+
self.chat_completion_url = f"{api_host}/chat/completions"
|
27 |
+
self.openai_api_base = f"{api_host}"
|
28 |
self.balance_api_url = f"{api_host}/dashboard/billing/credit_grants"
|
29 |
self.usage_api_url = f"{api_host}/dashboard/billing/usage"
|
30 |
os.environ["OPENAI_API_BASE"] = api_host
|