From 8562623befc40b746402a42eff92cd386e8b8fab Mon Sep 17 00:00:00 2001 From: alex-makang Date: Fri, 7 Aug 2026 16:49:24 +0800 Subject: [PATCH] fix(rerank): set NvidiaRerank base_url for all models (#17988) ### What problem does this PR solve? `NvidiaRerank.__init__` only assigned `self.base_url` inside two model-specific `if` branches: ```python if self.model_name == "nvidia/nv-rerankqa-mistral-4b-v3": self.base_url = urljoin(base_url, "nv-rerankqa-mistral-4b-v3/reranking") if self.model_name == "nvidia/rerank-qa-mistral-4b": self.base_url = urljoin(base_url, "reranking") ``` Any other NVIDIA rerank model therefore left the attribute unset, and the first `_compute_rank()` call died with `AttributeError: 'NvidiaRerank' object has no attribute 'base_url'`. This is reachable in normal use: `conf/llm_factories.json` ships no NVIDIA rerank entries at all, so every NVIDIA rerank model has to be added by hand, and any name other than those two hardcoded strings crashes. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) Co-authored-by: Alex Ma --- rag/llm/rerank_model.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rag/llm/rerank_model.py b/rag/llm/rerank_model.py index 8a7082022d..954ff58971 100644 --- a/rag/llm/rerank_model.py +++ b/rag/llm/rerank_model.py @@ -202,6 +202,12 @@ class NvidiaRerank(Base): base_url = "https://ai.api.nvidia.com/v1/retrieval/nvidia/" self.model_name = model_name + # Default to NVIDIA's generic reranking endpoint. base_url used to be + # assigned only inside the two model-specific branches below, so any + # other model left the attribute unset and raised AttributeError on the + # first _compute_rank() call. + self.base_url = urljoin(base_url, "reranking") + if self.model_name == "nvidia/nv-rerankqa-mistral-4b-v3": self.base_url = urljoin(base_url, "nv-rerankqa-mistral-4b-v3/reranking")