From 0a5a2e67e8dc86546d483133583a0438d09eb0f2 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 23 Aug 2024 15:02:23 +0200 Subject: [PATCH] fix: uploaded files leaking to other user chats issue #4601 --- backend/apps/rag/utils.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/backend/apps/rag/utils.py b/backend/apps/rag/utils.py index 034f71292..82bead012 100644 --- a/backend/apps/rag/utils.py +++ b/backend/apps/rag/utils.py @@ -149,16 +149,20 @@ def query_collection( ): results = [] for collection_name in collection_names: - try: - result = query_doc( - collection_name=collection_name, - query=query, - k=k, - embedding_function=embedding_function, - ) - results.append(result) - except Exception: + if collection_name: + try: + result = query_doc( + collection_name=collection_name, + query=query, + k=k, + embedding_function=embedding_function, + ) + results.append(result) + except Exception: + pass + else: pass + return merge_and_sort_query_results(results, k=k) @@ -257,7 +261,7 @@ def get_rag_context( collection_names = ( file["collection_names"] if file["type"] == "collection" - else [file["collection_name"]] + else [file["collection_name"]] if file["collection_name"] else [] ) collection_names = set(collection_names).difference(extracted_collections)