From 875096384bd7643be49d84abe3d580073218cbf0 Mon Sep 17 00:00:00 2001 From: liwenju0 Date: Fri, 22 Nov 2024 22:34:34 +0800 Subject: [PATCH] when qwen rerank model not return ok, raise exception to notice user (#3593) ### What problem does this PR solve? When calling the Qwen rerank model, if the model does not return correctly, an exception should be raised to notify the user, rather than simply returning a value of 0, as this would be confusing to the user. ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- rag/llm/rerank_model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rag/llm/rerank_model.py b/rag/llm/rerank_model.py index 58ea0decb..e2eb3a93d 100644 --- a/rag/llm/rerank_model.py +++ b/rag/llm/rerank_model.py @@ -452,4 +452,5 @@ class QWenRerank(Base): for r in resp.output.results: rank[r.index] = r.relevance_score return rank, resp.usage.total_tokens - return rank, 0 \ No newline at end of file + else: + raise ValueError(f"Error calling QWenRerank model {self.model_name}: {resp.status_code} - {resp.text}")