Refine error message for re-rank model. (#5278)

### What problem does this PR solve?

#5261

### Type of change

- [x] Refactoring
This commit is contained in:
Kevin Hu 2025-02-24 13:01:34 +08:00 committed by GitHub
parent 041d72b755
commit 605cfdb8dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -236,15 +236,17 @@ def add_llm():
msg += f"\nFail to access model({mdl_nm})." + str(
e)
elif llm["model_type"] == LLMType.RERANK:
try:
mdl = RerankModel[factory](
key=llm["api_key"],
model_name=mdl_nm,
base_url=llm["api_base"]
)
try:
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)