From 8cf8121812b8c921ae99f0e9973cdd028c0b800f Mon Sep 17 00:00:00 2001 From: Phlogi Date: Sat, 5 Apr 2025 10:41:21 +0200 Subject: [PATCH] Update utils.py Avoid running any tasks for collections that failed to fetch data (have assigned None) --- backend/open_webui/retrieval/utils.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/open_webui/retrieval/utils.py b/backend/open_webui/retrieval/utils.py index 518a12136..b600080cf 100644 --- a/backend/open_webui/retrieval/utils.py +++ b/backend/open_webui/retrieval/utils.py @@ -320,11 +320,9 @@ def query_collection_with_hybrid_search( log.exception(f"Error when querying the collection with hybrid_search: {e}") return None, e - tasks = [ - (collection_name, query) - for collection_name in collection_names - for query in queries - ] + # Prepare tasks for all collections and queries + # Avoid running any tasks for collections that failed to fetch data (have assigned None) + tasks = [(cn, q) for cn in collection_names if collection_results[cn] is not None for q in queries] with ThreadPoolExecutor() as executor: future_results = [executor.submit(process_query, cn, q) for cn, q in tasks]