From 602aba5bc744a0f4a25b7cb5fe00eefbc0f0dd64 Mon Sep 17 00:00:00 2001 From: Tadashi Date: Wed, 25 Dec 2024 16:13:43 +0700 Subject: [PATCH] fix: file limiting in docstore --- libs/kotaemon/kotaemon/indices/vectorindex.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libs/kotaemon/kotaemon/indices/vectorindex.py b/libs/kotaemon/kotaemon/indices/vectorindex.py index 5bf77c3d..bc282157 100644 --- a/libs/kotaemon/kotaemon/indices/vectorindex.py +++ b/libs/kotaemon/kotaemon/indices/vectorindex.py @@ -177,7 +177,11 @@ class VectorRetrieval(BaseRetrieval): ] elif self.retrieval_mode == "text": query = text.text if isinstance(text, Document) else text - docs = self.doc_store.query(query, top_k=top_k_first_round, doc_ids=scope) + docs = [] + if scope: + docs = self.doc_store.query( + query, top_k=top_k_first_round, doc_ids=scope + ) result = [RetrievedDocument(**doc.to_dict(), score=-1.0) for doc in docs] elif self.retrieval_mode == "hybrid": # similarity search section @@ -206,9 +210,10 @@ class VectorRetrieval(BaseRetrieval): assert self.doc_store is not None query = text.text if isinstance(text, Document) else text - ds_docs = self.doc_store.query( - query, top_k=top_k_first_round, doc_ids=scope - ) + if scope: + ds_docs = self.doc_store.query( + query, top_k=top_k_first_round, doc_ids=scope + ) vs_query_thread = threading.Thread(target=query_vectorstore) ds_query_thread = threading.Thread(target=query_docstore)