community: add score to PineconeHybridSearchRetriever (#25781)

**Description:**

Adds the 'score' returned by Pinecone to the
`PineconeHybridSearchRetriever` list of returned Documents.

There is currently no way to return the score when using Pinecone hybrid
search, so in this PR I include it by default.

---------

Co-authored-by: Chester Curme <chester.curme@gmail.com>
pull/23219/head^2
Cillian Berragan 3 weeks ago committed by GitHub
parent 3f1d652f15
commit 754f3c41f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -173,8 +173,9 @@ class PineconeHybridSearchRetriever(BaseRetriever):
final_result = []
for res in result["matches"]:
context = res["metadata"].pop("context")
final_result.append(
Document(page_content=context, metadata=res["metadata"])
)
metadata = res["metadata"]
if "score" not in metadata and "score" in res:
metadata["score"] = res["score"]
final_result.append(Document(page_content=context, metadata=metadata))
# return search results as json
return final_result

Loading…
Cancel
Save