From 92c90683696bc46516f06a0eaf5579ee7038e234 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 14 Jul 2025 17:50:03 +0400 Subject: [PATCH] refac --- backend/open_webui/retrieval/utils.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/open_webui/retrieval/utils.py b/backend/open_webui/retrieval/utils.py index 087fd9208c..154873749f 100644 --- a/backend/open_webui/retrieval/utils.py +++ b/backend/open_webui/retrieval/utils.py @@ -488,8 +488,12 @@ def get_sources_from_items( if item.get("file"): # if item has file data, use it query_result = { - "documents": [[item.get("file").get("data", {}).get("content")]], - "metadatas": [[item.get("file").get("data", {}).get("meta", {})]], + "documents": [ + [item.get("file", {}).get("data", {}).get("content")] + ], + "metadatas": [ + [item.get("file", {}).get("data", {}).get("meta", {})] + ], } else: # Fallback to item content @@ -516,12 +520,12 @@ def get_sources_from_items( item.get("context") == "full" or request.app.state.config.BYPASS_EMBEDDING_AND_RETRIEVAL ): - if item.get("file").get("data", {}): + if item.get("file", {}).get("data", {}).get("content", ""): # Manual Full Mode Toggle # Used from chat file modal, we can assume that the file content will be available from item.get("file").get("data", {}).get("content") query_result = { "documents": [ - [item.get("file").get("data", {}).get("content", "")] + [item.get("file", {}).get("data", {}).get("content", "")] ], "metadatas": [ [