[Bug fix] Fix search API for pinecone vector db

This commit is contained in:
Deshraj Yadav
2024-03-01 16:44:42 -08:00
parent 91044ec591
commit 7e1d2ffdd7
3 changed files with 7 additions and 2 deletions

View File

@@ -588,7 +588,7 @@ class EmbedChain(JSONSerializable):
else: else:
return answer return answer
def search(self, query, num_documents=3, where=None, raw_filter=None): def search(self, query, num_documents=3, where=None, raw_filter=None, namespace=None):
""" """
Search for similar documents related to the query in the vector database. Search for similar documents related to the query in the vector database.
@@ -597,6 +597,7 @@ class EmbedChain(JSONSerializable):
num_documents (int, optional): Number of similar documents to fetch. Defaults to 3. num_documents (int, optional): Number of similar documents to fetch. Defaults to 3.
where (dict[str, any], optional): Filter criteria for the search. where (dict[str, any], optional): Filter criteria for the search.
raw_filter (dict[str, any], optional): Advanced raw filter criteria for the search. raw_filter (dict[str, any], optional): Advanced raw filter criteria for the search.
namespace (str, optional): The namespace to search in. Defaults to None.
Raises: Raises:
ValueError: If both `raw_filter` and `where` are used simultaneously. ValueError: If both `raw_filter` and `where` are used simultaneously.
@@ -618,6 +619,7 @@ class EmbedChain(JSONSerializable):
"n_results": num_documents, "n_results": num_documents,
"citations": True, "citations": True,
"app_id": self.config.id, "app_id": self.config.id,
"namespace": namespace,
filter_type: filter_criteria, filter_type: filter_criteria,
} }

View File

@@ -230,6 +230,9 @@ class PineconeDB(BaseVectorDB):
@staticmethod @staticmethod
def _generate_filter(where: dict): def _generate_filter(where: dict):
query = {} query = {}
if where is None:
return query
for k, v in where.items(): for k, v in where.items():
query[k] = {"$eq": v} query[k] = {"$eq": v}
return query return query

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "embedchain" name = "embedchain"
version = "0.1.90" version = "0.1.91"
description = "Simplest open source retrieval(RAG) framework" description = "Simplest open source retrieval(RAG) framework"
authors = [ authors = [
"Taranjeet Singh <taranjeet@embedchain.ai>", "Taranjeet Singh <taranjeet@embedchain.ai>",