Skip to content

Commit

Permalink
Merge pull request #1407 from zc277584121/main
Browse files Browse the repository at this point in the history
fix milvus issues
  • Loading branch information
dartpain authored Nov 6, 2024
2 parents 1f52461 + 7fd8e57 commit 7fed92d
Showing 1 changed file with 4 additions and 3 deletions.
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 7fed92d

Please sign in to comment.