Update app.py
Browse files
app.py
CHANGED
|
@@ -101,10 +101,12 @@ def refresh_models():
|
|
| 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 =
|
| 107 |
-
|
|
|
|
|
|
|
| 108 |
free_text_models = []
|
| 109 |
free_embedding_models = []
|
| 110 |
|
|
@@ -145,24 +147,6 @@ def refresh_models():
|
|
| 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}")
|
|
|
|
| 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 = {
|
| 107 |
+
sub_type: get_all_models(FREE_MODEL_TEST_KEY, sub_type)
|
| 108 |
+
for sub_type in ["embedding", "reranker"]
|
| 109 |
+
}
|
| 110 |
free_text_models = []
|
| 111 |
free_embedding_models = []
|
| 112 |
|
|
|
|
| 147 |
except Exception as exc:
|
| 148 |
logging.error(f"模型 {model} 测试生成异常: {exc}")
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
logging.info(f"所有文本模型列表:{text_models}")
|
| 151 |
logging.info(f"免费文本模型列表:{free_text_models}")
|
| 152 |
logging.info(f"所有向量模型列表:{embedding_models}")
|