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:
parent
b5b8032a56
commit
a0d630365c
1 changed files with 3 additions and 2 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue