Refactor:Improve VoyageRerank not texts handling (#9539)

### What problem does this PR solve?

Improve VoyageRerank not texts handling

### Type of change

- [x] Refactoring
This commit is contained in:
Stephen Hu
2025-08-19 10:31:04 +08:00
committed by GitHub
parent b5b8032a56
commit a0d630365c

View File

@ -482,9 +482,10 @@ class VoyageRerank(Base):
self.model_name = model_name
def similarity(self, query: str, texts: list):
rank = np.zeros(len(texts), dtype=float)
if not texts:
return rank, 0
return np.array([]), 0
rank = np.zeros(len(texts), dtype=float)
res = self.client.rerank(query=query, documents=texts, model=self.model_name, top_k=len(texts))
try:
for r in res.results: