From 605cfdb8dcf39349121ec458d6d727ea642d6674 Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Mon, 24 Feb 2025 13:01:34 +0800 Subject: [PATCH] Refine error message for re-rank model. (#5278) ### What problem does this PR solve? #5261 ### Type of change - [x] Refactoring --- api/apps/llm_app.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/api/apps/llm_app.py b/api/apps/llm_app.py index 71b6affc8..0ccb468bd 100644 --- a/api/apps/llm_app.py +++ b/api/apps/llm_app.py @@ -236,15 +236,17 @@ def add_llm(): msg += f"\nFail to access model({mdl_nm})." + str( e) elif llm["model_type"] == LLMType.RERANK: - mdl = RerankModel[factory]( - key=llm["api_key"], - model_name=mdl_nm, - base_url=llm["api_base"] - ) try: + mdl = RerankModel[factory]( + key=llm["api_key"], + model_name=mdl_nm, + base_url=llm["api_base"] + ) arr, tc = mdl.similarity("Hello~ Ragflower!", ["Hi, there!", "Ohh, my friend!"]) if len(arr) == 0: raise Exception("Not known.") + except KeyError: + msg += f"{factory} dose not support this model({mdl_nm})" except Exception as e: msg += f"\nFail to access model({mdl_nm})." + str( e)