diff --git a/backend/open_webui/apps/retrieval/utils.py b/backend/open_webui/apps/retrieval/utils.py index cfae8a80b..12c30edbb 100644 --- a/backend/open_webui/apps/retrieval/utils.py +++ b/backend/open_webui/apps/retrieval/utils.py @@ -319,7 +319,7 @@ def get_rag_context( for file in files: if file.get("context") == "full": context = { - "documents": [[file["content"]]], + "documents": [[file.get("file").get("content")]], "metadatas": [[{"file_id": file.get("id"), "name": file.get("name")}]], } else: diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index e3ae32e39..121a23205 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -150,7 +150,10 @@ if (res) { fileItem.status = 'processed'; fileItem.collection_name = res.collection_name; - fileItem.content = res.content; + fileItem.file = { + ...fileItem.file, + content: res.content + }; files = files; } diff --git a/src/lib/components/chat/MessageInput/Commands.svelte b/src/lib/components/chat/MessageInput/Commands.svelte index 91f78866d..8be6d5f87 100644 --- a/src/lib/components/chat/MessageInput/Commands.svelte +++ b/src/lib/components/chat/MessageInput/Commands.svelte @@ -46,14 +46,17 @@ if (res) { fileItem.status = 'processed'; fileItem.collection_name = res.collection_name; - fileItem.content = res.content; + fileItem.file = { + content: res.content, + ...fileItem.file + }; files = files; } } catch (e) { // Remove the failed doc from the files array files = files.filter((f) => f.name !== url); - toast.error(e); + toast.error(JSON.stringify(e)); } }; @@ -76,7 +79,10 @@ if (res) { fileItem.status = 'processed'; fileItem.collection_name = res.collection_name; - fileItem.content = res.content; + fileItem.file = { + content: res.content, + ...fileItem.file + }; files = files; } } catch (e) { diff --git a/src/lib/components/common/FileItem.svelte b/src/lib/components/common/FileItem.svelte index 51fb44f2b..316587b18 100644 --- a/src/lib/components/common/FileItem.svelte +++ b/src/lib/components/common/FileItem.svelte @@ -33,7 +33,7 @@ class="h-14 {className} flex items-center space-x-3 {colorClassName} rounded-xl border border-gray-100 dark:border-gray-800 text-left" type="button" on:click={async () => { - if (file.content) { + if (file?.file?.content) { showModal = !showModal; } else { if (url) { diff --git a/src/lib/components/common/FileItemModal.svelte b/src/lib/components/common/FileItemModal.svelte index 70755885a..6cb6402ff 100644 --- a/src/lib/components/common/FileItemModal.svelte +++ b/src/lib/components/common/FileItemModal.svelte @@ -61,8 +61,10 @@ • {/if} - {#if file.content} -