fix milvus issues

Signed-off-by: ChengZi <chen.zhang@zilliz.com>
This commit is contained in:
ChengZi
2024-11-04 17:58:56 +08:00
parent dbfc1bb68f
commit 171916e1a4
2 changed files with 5 additions and 3 deletions

View File

@@ -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

View File

@@ -7,7 +7,7 @@ from application.vectorstore.base import BaseVectorStore
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 @@ class MilvusStore(BaseVectorStore):
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))]