mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 15:31:05 +08:00
fix: optimize reranking module robustness and bug fixes (#14264)
## Description This PR fixes critical bugs and improves the robustness of the RAG reranking module while maintaining **100% backward compatibility** with all existing functionality and providers. ## Key Changes 1. **Network Stability**: Added 30s timeout to all API requests to prevent service blocking 2. **Boundary Protection**: Added empty query/text validation for all rerank models 3. **Response Fault Tolerance**: Replaced hardcoded key access with `.get()` to avoid KeyError crashes 4. **Bug Fixes**: - Fixed `Ai302Rerank` (completely non-functional before) - Fixed `GPUStackRerank` incorrect exception catching - Fixed `_normalize_rank` empty array crash 5. **Code Specification**: Added type annotations, standardized unimplemented class prompts ## Compatibility - ✅ No changes to any class/method names - ✅ All rerank providers (Jina/Cohere/NVIDIA/HuggingFace etc.) work as before - ✅ No breaking changes, zero impact on existing workflows ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) - [x] Refactoring --------- Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
@@ -435,6 +435,7 @@ class HuggingfaceRerank(Base):
|
||||
|
||||
for i in range(0, len(texts), batch_size):
|
||||
try:
|
||||
# Fix: Add request timeout
|
||||
res = requests.post(
|
||||
endpoint, headers={"Content-Type": "application/json"},
|
||||
json={"query": query, "texts": texts[i:i+batch_size], "raw_scores": False, "truncate": True},
|
||||
|
||||
Reference in New Issue
Block a user