fix: hybrid search

This commit is contained in:
Timothy J. Baek 2024-09-13 01:21:47 -04:00
parent 939bfd153e
commit 823093eea6
3 changed files with 3 additions and 6 deletions

View File

@ -97,8 +97,8 @@ def query_doc_with_hybrid_search(
result = VECTOR_DB_CLIENT.get(collection_name=collection_name) result = VECTOR_DB_CLIENT.get(collection_name=collection_name)
bm25_retriever = BM25Retriever.from_texts( bm25_retriever = BM25Retriever.from_texts(
texts=result.documents, texts=result.documents[0],
metadatas=result.metadatas, metadatas=result.metadatas[0],
) )
bm25_retriever.k = k bm25_retriever.k = k

View File

@ -70,13 +70,10 @@ class ChromaClient:
# Get all the items in the collection. # Get all the items in the collection.
collection = self.client.get_collection(name=collection_name) collection = self.client.get_collection(name=collection_name)
if collection: if collection:
result = collection.get() result = collection.get()
return GetResult( return GetResult(
**{ **{
"ids": [result["ids"]], "ids": [result["ids"]],
"distances": [result["distances"]],
"documents": [result["documents"]], "documents": [result["documents"]],
"metadatas": [result["metadatas"]], "metadatas": [result["metadatas"]],
} }

View File

@ -113,7 +113,7 @@ class MilvusClient:
collection_name=f"{self.collection_prefix}_{collection_name}", collection_name=f"{self.collection_prefix}_{collection_name}",
filter='id != ""', filter='id != ""',
) )
return self._result_to_query_result(result) return GetResult(**self._result_to_query_result(result))
def insert(self, collection_name: str, items: list[VectorItem]): def insert(self, collection_name: str, items: list[VectorItem]):
# Insert the items into the collection, if the collection does not exist, it will be created. # Insert the items into the collection, if the collection does not exist, it will be created.