mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-05 15:20:30 +08:00
fix: handle qwen rerank error response (#15881)
### What problem does this PR solve? Fix QWen rerank error handling so DashScope error responses without a text attribute do not raise a secondary KeyError and hide the real provider error. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -432,7 +432,16 @@ class QWenRerank(Base):
|
||||
log_exception(_e, resp)
|
||||
return rank, total_token_count_from_response(resp)
|
||||
else:
|
||||
raise ValueError(f"Error calling QWenRerank model {self.model_name}: {resp.status_code} - {resp.text}")
|
||||
try:
|
||||
error_body = resp["text"] if isinstance(resp, dict) and "text" in resp else None
|
||||
except Exception:
|
||||
error_body = None
|
||||
if not error_body:
|
||||
try:
|
||||
error_body = json.dumps(dict(resp), ensure_ascii=False)
|
||||
except Exception:
|
||||
error_body = str(resp)
|
||||
raise ValueError(f"Error calling QWenRerank model {self.model_name}: {resp.status_code} - {error_body}")
|
||||
|
||||
|
||||
class HuggingfaceRerank(Base):
|
||||
|
||||
Reference in New Issue
Block a user