Skip to content

Commit

Permalink
nvidia rerank top n missed (langgenius#8185)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnJyong authored and cuiks committed Sep 26, 2024
1 parent 1ec6ab9 commit 8ab1dce
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def _invoke(self, model: str, credentials: dict,
"query": {"text": query},
"passages": [{"text": doc} for doc in docs],
}

session = requests.Session()
response = session.post(invoke_url, headers=headers, json=payload)
response.raise_for_status()
Expand All @@ -71,7 +70,10 @@ def _invoke(self, model: str, credentials: dict,
)

rerank_documents.append(rerank_document)

if rerank_documents:
rerank_documents = sorted(rerank_documents, key=lambda x: x.score, reverse=True)
if top_n:
rerank_documents = rerank_documents[:top_n]
return RerankResult(model=model, docs=rerank_documents)
except requests.HTTPError as e:
raise InvokeServerUnavailableError(str(e))
Expand Down

0 comments on commit 8ab1dce

Please sign in to comment.