From ee22ba9676c44572c86633f319729b0001df26f2 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 6 Oct 2024 19:44:02 -0700 Subject: [PATCH] fix: web, youtube attachment issue --- backend/open_webui/apps/retrieval/main.py | 26 ++++++++++++++----- .../chat/MessageInput/Commands.svelte | 12 ++++----- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/backend/open_webui/apps/retrieval/main.py b/backend/open_webui/apps/retrieval/main.py index 9fedd6575..52cebeabc 100644 --- a/backend/open_webui/apps/retrieval/main.py +++ b/backend/open_webui/apps/retrieval/main.py @@ -923,15 +923,22 @@ def process_youtube_video(form_data: ProcessUrlForm, user=Depends(get_verified_u translation=app.state.YOUTUBE_LOADER_TRANSLATION, ) docs = loader.load() - text_content = " ".join([doc.page_content for doc in docs]) - log.debug(f"text_content: {text_content}") + content = " ".join([doc.page_content for doc in docs]) + log.debug(f"text_content: {content}") save_docs_to_vector_db(docs, collection_name, overwrite=True) return { "status": True, "collection_name": collection_name, "filename": form_data.url, - "content": text_content, + "file": { + "data": { + "content": content, + }, + "meta": { + "name": form_data.url, + }, + }, } except Exception as e: log.exception(e) @@ -954,15 +961,22 @@ def process_web(form_data: ProcessUrlForm, user=Depends(get_verified_user)): requests_per_second=app.state.config.RAG_WEB_SEARCH_CONCURRENT_REQUESTS, ) docs = loader.load() - text_content = " ".join([doc.page_content for doc in docs]) - log.debug(f"text_content: {text_content}") + content = " ".join([doc.page_content for doc in docs]) + log.debug(f"text_content: {content}") save_docs_to_vector_db(docs, collection_name, overwrite=True) return { "status": True, "collection_name": collection_name, "filename": form_data.url, - "content": text_content, + "file": { + "data": { + "content": content, + }, + "meta": { + "name": form_data.url, + }, + }, } except Exception as e: log.exception(e) diff --git a/src/lib/components/chat/MessageInput/Commands.svelte b/src/lib/components/chat/MessageInput/Commands.svelte index d23c4c8d8..9ce943364 100644 --- a/src/lib/components/chat/MessageInput/Commands.svelte +++ b/src/lib/components/chat/MessageInput/Commands.svelte @@ -34,7 +34,7 @@ type: 'doc', name: url, collection_name: '', - status: false, + status: 'uploading', url: url, error: '' }; @@ -44,10 +44,10 @@ const res = await processWeb(localStorage.token, '', url); if (res) { - fileItem.status = 'processed'; + fileItem.status = 'uploaded'; fileItem.collection_name = res.collection_name; fileItem.file = { - content: res.content, + ...res.file, ...fileItem.file }; @@ -67,7 +67,7 @@ type: 'doc', name: url, collection_name: '', - status: false, + status: 'uploading', url: url, error: '' }; @@ -77,10 +77,10 @@ const res = await processYoutubeVideo(localStorage.token, url); if (res) { - fileItem.status = 'processed'; + fileItem.status = 'uploaded'; fileItem.collection_name = res.collection_name; fileItem.file = { - content: res.content, + ...res.file, ...fileItem.file }; files = files;