mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
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>
This commit is contained in:
parent
3f1d652f15
commit
754f3c41f9
@ -173,8 +173,9 @@ class PineconeHybridSearchRetriever(BaseRetriever):
|
|||||||
final_result = []
|
final_result = []
|
||||||
for res in result["matches"]:
|
for res in result["matches"]:
|
||||||
context = res["metadata"].pop("context")
|
context = res["metadata"].pop("context")
|
||||||
final_result.append(
|
metadata = res["metadata"]
|
||||||
Document(page_content=context, 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 search results as json
|
||||||
return final_result
|
return final_result
|
||||||
|
Loading…
Reference in New Issue
Block a user