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 <alex_makang@hotmail.com>
This commit is contained in:
alex-makang
2026-08-07 16:49:24 +08:00
committed by GitHub
parent 1aa4e3c1f3
commit 8562623bef

View File

@@ -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")