From 171916e1a4e44c8dc81b7e91d220946f4017310f Mon Sep 17 00:00:00 2001 From: ChengZi Date: Mon, 4 Nov 2024 17:58:56 +0800 Subject: [PATCH 1/2] fix milvus issues Signed-off-by: ChengZi --- application/requirements.txt | 1 + application/vectorstore/milvus.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/application/requirements.txt b/application/requirements.txt index 2f28c2ea6..97ab7eb81 100644 --- a/application/requirements.txt +++ b/application/requirements.txt @@ -31,6 +31,7 @@ kombu==5.4.2 langchain==0.3.0 langchain-community==0.3.0 langchain-core==0.3.2 +langchain-milvus==0.1.6 langchain-openai==0.2.0 langchain-text-splitters==0.3.0 langsmith==0.1.125 diff --git a/application/vectorstore/milvus.py b/application/vectorstore/milvus.py index 9871991e2..d43806660 100644 --- a/application/vectorstore/milvus.py +++ b/application/vectorstore/milvus.py @@ -7,7 +7,7 @@ class MilvusStore(BaseVectorStore): - def __init__(self, path: str = "", embeddings_key: str = "embeddings"): + def __init__(self, source_id: str = "", embeddings_key: str = "embeddings"): super().__init__() from langchain_milvus import Milvus @@ -20,10 +20,11 @@ def __init__(self, path: str = "", embeddings_key: str = "embeddings"): collection_name=settings.MILVUS_COLLECTION_NAME, connection_args=connection_args, ) - self._path = path + self._source_id = source_id def search(self, question, k=2, *args, **kwargs): - return self._docsearch.similarity_search(query=question, k=k, filter={"path": self._path} *args, **kwargs) + expr = f"source_id == '{self._source_id}'" + return self._docsearch.similarity_search(query=question, k=k, expr=expr, *args, **kwargs) def add_texts(self, texts: List[str], metadatas: Optional[List[dict]], *args, **kwargs): ids = [str(uuid4()) for _ in range(len(texts))] From 7fd8e57bdc0dd277dd1f76b690b5f11d136bf5f7 Mon Sep 17 00:00:00 2001 From: ChengZi Date: Wed, 6 Nov 2024 10:30:18 +0800 Subject: [PATCH 2/2] remove milvus dependency from req.txt Signed-off-by: ChengZi --- application/requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/application/requirements.txt b/application/requirements.txt index 97ab7eb81..2f28c2ea6 100644 --- a/application/requirements.txt +++ b/application/requirements.txt @@ -31,7 +31,6 @@ kombu==5.4.2 langchain==0.3.0 langchain-community==0.3.0 langchain-core==0.3.2 -langchain-milvus==0.1.6 langchain-openai==0.2.0 langchain-text-splitters==0.3.0 langsmith==0.1.125