Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -100,12 +100,31 @@ def refresh_models():
|
|
100 |
"""
|
101 |
global text_models, free_text_models
|
102 |
global embedding_models, free_embedding_models
|
103 |
-
|
104 |
text_models = get_all_models(FREE_MODEL_TEST_KEY, "chat")
|
105 |
embedding_models = get_all_models(FREE_MODEL_TEST_KEY, "embedding")
|
106 |
free_text_models = []
|
107 |
free_embedding_models = []
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
with concurrent.futures.ThreadPoolExecutor(
|
110 |
max_workers=10
|
111 |
) as executor:
|
|
|
100 |
"""
|
101 |
global text_models, free_text_models
|
102 |
global embedding_models, free_embedding_models
|
103 |
+
|
104 |
text_models = get_all_models(FREE_MODEL_TEST_KEY, "chat")
|
105 |
embedding_models = get_all_models(FREE_MODEL_TEST_KEY, "embedding")
|
106 |
free_text_models = []
|
107 |
free_embedding_models = []
|
108 |
|
109 |
+
ban_models_str = os.environ.get("BAN_MODELS")
|
110 |
+
ban_models = []
|
111 |
+
if ban_models_str:
|
112 |
+
try:
|
113 |
+
ban_models = json.loads(ban_models_str)
|
114 |
+
if not isinstance(ban_models, list):
|
115 |
+
logging.warning(
|
116 |
+
"环境变量 BAN_MODELS 格式不正确,应为 JSON 数组。"
|
117 |
+
)
|
118 |
+
ban_models = []
|
119 |
+
except json.JSONDecodeError:
|
120 |
+
logging.warning(
|
121 |
+
"环境变量 BAN_MODELS JSON 解析失败,请检查格式。"
|
122 |
+
)
|
123 |
+
ban_models = []
|
124 |
+
|
125 |
+
text_models = [model for model in text_models if model not in ban_models]
|
126 |
+
embedding_models = [model for model in embedding_models if model not in ban_models]
|
127 |
+
|
128 |
with concurrent.futures.ThreadPoolExecutor(
|
129 |
max_workers=10
|
130 |
) as executor:
|