Spaces:
Paused
Paused
ReeInk
commited on
Commit
•
8865b23
1
Parent(s):
e5e3e0a
修复:读取环境变量重定向URL格式
Browse files- toolbox.py +5 -7
toolbox.py
CHANGED
@@ -545,13 +545,11 @@ def read_single_conf_from_env(arg, default_value):
|
|
545 |
# 格式为:username1:password1;username2:password2
|
546 |
for item in os.environ[env_arg].split(";"):
|
547 |
r.append(tuple(item.split(":")))
|
548 |
-
elif arg == "API_URL_REDIRECT":
|
549 |
-
|
550 |
-
#
|
551 |
-
|
552 |
-
|
553 |
-
k, v = item.split(":")
|
554 |
-
r[k] = v
|
555 |
elif isinstance(default_value, bool):
|
556 |
r = bool(os.environ[env_arg])
|
557 |
elif isinstance(default_value, int):
|
|
|
545 |
# 格式为:username1:password1;username2:password2
|
546 |
for item in os.environ[env_arg].split(";"):
|
547 |
r.append(tuple(item.split(":")))
|
548 |
+
elif arg == "API_URL_REDIRECT":
|
549 |
+
# 对于API_URL_REDIRECT的环境变量,我们允许用户使用json格式配置多个url重定向
|
550 |
+
# 格式为一个json字符串,例如:{"https://api.openai.com/v1/chat/completions": "https://ai.open.com/api/conversation"}
|
551 |
+
import json
|
552 |
+
r = json.loads(os.environ[env_arg])
|
|
|
|
|
553 |
elif isinstance(default_value, bool):
|
554 |
r = bool(os.environ[env_arg])
|
555 |
elif isinstance(default_value, int):
|