From 171916e1a4e44c8dc81b7e91d220946f4017310f Mon Sep 17 00:00:00 2001 From: ChengZi Date: Mon, 4 Nov 2024 17:58:56 +0800 Subject: [PATCH 1/3] 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 2f28c2ea..97ab7eb8 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 9871991e..d4380666 100644 --- a/application/vectorstore/milvus.py +++ b/application/vectorstore/milvus.py @@ -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))] From 7fd8e57bdc0dd277dd1f76b690b5f11d136bf5f7 Mon Sep 17 00:00:00 2001 From: ChengZi Date: Wed, 6 Nov 2024 10:30:18 +0800 Subject: [PATCH 2/3] 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 97ab7eb8..2f28c2ea 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 From ebbd47c9cbdb5726b7e9b0aed00b58a8994ac7c9 Mon Sep 17 00:00:00 2001 From: Siddhant Rai Date: Wed, 6 Nov 2024 21:34:57 +0530 Subject: [PATCH 3/3] fix: pending sources even when no sources provided --- frontend/src/conversation/conversationSlice.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/conversation/conversationSlice.ts b/frontend/src/conversation/conversationSlice.ts index 1b7e9d41..3ca05c7b 100644 --- a/frontend/src/conversation/conversationSlice.ts +++ b/frontend/src/conversation/conversationSlice.ts @@ -20,6 +20,7 @@ const API_STREAMING = import.meta.env.VITE_API_STREAMING === 'true'; export const fetchAnswer = createAsyncThunk( 'fetchAnswer', async ({ question }, { dispatch, getState, signal }) => { + let isSourceUpdated = false; const state = getState() as RootState; if (state.preference) { if (API_STREAMING) { @@ -36,9 +37,7 @@ export const fetchAnswer = createAsyncThunk( (event) => { const data = JSON.parse(event.data); - // check if the 'end' event has been received if (data.type === 'end') { - // set status to 'idle' dispatch(conversationSlice.actions.setStatus('idle')); getConversations() .then((fetchedConversations) => { @@ -47,6 +46,14 @@ export const fetchAnswer = createAsyncThunk( .catch((error) => { console.error('Failed to fetch conversations: ', error); }); + if (!isSourceUpdated) { + dispatch( + updateStreamingSource({ + index: state.conversation.queries.length - 1, + query: { sources: [] }, + }), + ); + } } else if (data.type === 'id') { dispatch( updateConversationId({ @@ -54,6 +61,7 @@ export const fetchAnswer = createAsyncThunk( }), ); } else if (data.type === 'source') { + isSourceUpdated = true; dispatch( updateStreamingSource({ index: state.conversation.queries.length - 1,