From 4e763e8aa89a8532626351a6c2f904c4f133f49e Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 9 Oct 2025 16:16:24 -0500 Subject: [PATCH] refac --- backend/open_webui/retrieval/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/open_webui/retrieval/utils.py b/backend/open_webui/retrieval/utils.py index 66a7fa2ddf..69aee29ac2 100644 --- a/backend/open_webui/retrieval/utils.py +++ b/backend/open_webui/retrieval/utils.py @@ -268,6 +268,13 @@ def merge_and_sort_query_results(query_results: list[dict], k: int) -> dict: combined = dict() # To store documents with unique document hashes for data in query_results: + if ( + len(data.get("distances", [])) == 0 + or len(data.get("documents", [])) == 0 + or len(data.get("metadatas", [])) == 0 + ): + continue + distances = data["distances"][0] documents = data["documents"][0] metadatas = data["metadatas"][0]