[Feature] Return score when doing search in vectorDB (#1060)

Co-authored-by: Deven Patel <deven298@yahoo.com>
This commit is contained in:
Deven Patel
2023-12-29 15:56:12 +05:30
committed by GitHub
parent 19d80914df
commit c0aafd38c9
12 changed files with 72 additions and 28 deletions

View File

@@ -164,7 +164,7 @@ class ElasticsearchDB(BaseVectorDB):
skip_embedding: bool,
citations: bool = False,
**kwargs: Optional[Dict[str, Any]],
) -> Union[List[Tuple[str, str, str]], List[str]]:
) -> Union[List[Tuple[str, Dict]], List[str]]:
"""
query contents from vector data base based on vector similarity
@@ -210,6 +210,7 @@ class ElasticsearchDB(BaseVectorDB):
context = doc["_source"]["text"]
if citations:
metadata = doc["_source"]["metadata"]
metadata["score"] = doc["_score"]
contexts.append(tuple((context, metadata)))
else:
contexts.append(context)