Skip to content

Commit

Permalink
fix milvus issues
Browse files Browse the repository at this point in the history
Signed-off-by: ChengZi <[email protected]>
  • Loading branch information
zc277584121 committed Nov 4, 2024
1 parent dbfc1bb commit 171916e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions application/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions application/vectorstore/milvus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))]
Expand Down

0 comments on commit 171916e

Please sign in to comment.