Update app.py
Browse files
app.py
CHANGED
|
@@ -99,11 +99,12 @@ def refresh_models():
|
|
| 99 |
"""
|
| 100 |
刷新模型列表和免费模型列表。
|
| 101 |
"""
|
| 102 |
-
global
|
| 103 |
global embedding_models, free_embedding_models
|
| 104 |
|
| 105 |
-
|
| 106 |
embedding_models = get_all_models(FREE_MODEL_TEST_KEY, "embedding")
|
|
|
|
| 107 |
free_models = []
|
| 108 |
free_embedding_models = []
|
| 109 |
|
|
@@ -115,14 +116,14 @@ def refresh_models():
|
|
| 115 |
test_model_availability,
|
| 116 |
FREE_MODEL_TEST_KEY,
|
| 117 |
model
|
| 118 |
-
): model for model in
|
| 119 |
}
|
| 120 |
for future in concurrent.futures.as_completed(future_to_model):
|
| 121 |
model = future_to_model[future]
|
| 122 |
try:
|
| 123 |
is_free = future.result()
|
| 124 |
if is_free:
|
| 125 |
-
|
| 126 |
except Exception as exc:
|
| 127 |
logging.error(f"模型 {model} 测试生成异常: {exc}")
|
| 128 |
|
|
@@ -144,8 +145,26 @@ def refresh_models():
|
|
| 144 |
except Exception as exc:
|
| 145 |
logging.error(f"模型 {model} 测试生成异常: {exc}")
|
| 146 |
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
logging.info(f"所有向量模型列表:{embedding_models}")
|
| 150 |
logging.info(f"免费向量模型列表:{free_embedding_models}")
|
| 151 |
|
|
|
|
| 99 |
"""
|
| 100 |
刷新模型列表和免费模型列表。
|
| 101 |
"""
|
| 102 |
+
global text_models, free_text_models
|
| 103 |
global embedding_models, free_embedding_models
|
| 104 |
|
| 105 |
+
text_models = get_all_models(FREE_MODEL_TEST_KEY, "chat")
|
| 106 |
embedding_models = get_all_models(FREE_MODEL_TEST_KEY, "embedding")
|
| 107 |
+
reranker_models = get_all_models(FREE_MODEL_TEST_KEY, "reranker")
|
| 108 |
free_models = []
|
| 109 |
free_embedding_models = []
|
| 110 |
|
|
|
|
| 116 |
test_model_availability,
|
| 117 |
FREE_MODEL_TEST_KEY,
|
| 118 |
model
|
| 119 |
+
): model for model in text_models
|
| 120 |
}
|
| 121 |
for future in concurrent.futures.as_completed(future_to_model):
|
| 122 |
model = future_to_model[future]
|
| 123 |
try:
|
| 124 |
is_free = future.result()
|
| 125 |
if is_free:
|
| 126 |
+
free_text_models.append(model)
|
| 127 |
except Exception as exc:
|
| 128 |
logging.error(f"模型 {model} 测试生成异常: {exc}")
|
| 129 |
|
|
|
|
| 145 |
except Exception as exc:
|
| 146 |
logging.error(f"模型 {model} 测试生成异常: {exc}")
|
| 147 |
|
| 148 |
+
with concurrent.futures.ThreadPoolExecutor(
|
| 149 |
+
max_workers=10
|
| 150 |
+
) as executor:
|
| 151 |
+
future_to_model = {
|
| 152 |
+
executor.submit(
|
| 153 |
+
test_embedding_model_availability,
|
| 154 |
+
FREE_MODEL_TEST_KEY, model
|
| 155 |
+
): model for model in reranker_models
|
| 156 |
+
}
|
| 157 |
+
for future in concurrent.futures.as_completed(future_to_model):
|
| 158 |
+
model = future_to_model[future]
|
| 159 |
+
try:
|
| 160 |
+
is_free = future.result()
|
| 161 |
+
if is_free:
|
| 162 |
+
free_embedding_models.append(model)
|
| 163 |
+
except Exception as exc:
|
| 164 |
+
logging.error(f"模型 {model} 测试生成异常: {exc}")
|
| 165 |
+
|
| 166 |
+
logging.info(f"所有文本模型列表:{text_models}")
|
| 167 |
+
logging.info(f"免费文本模型列表:{free_text_models}")
|
| 168 |
logging.info(f"所有向量模型列表:{embedding_models}")
|
| 169 |
logging.info(f"免费向量模型列表:{free_embedding_models}")
|
| 170 |
|