From e36acd6217a7d6ed703f8873a022a85a1031a74a Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sat, 26 Oct 2024 13:05:54 -0700 Subject: [PATCH] enh: empty file handling behaviour --- backend/open_webui/apps/webui/routers/files.py | 2 +- src/lib/components/chat/MessageInput.svelte | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/apps/webui/routers/files.py b/backend/open_webui/apps/webui/routers/files.py index 551b6d788..b8695eb67 100644 --- a/backend/open_webui/apps/webui/routers/files.py +++ b/backend/open_webui/apps/webui/routers/files.py @@ -76,7 +76,7 @@ def upload_file(file: UploadFile = File(...), user=Depends(get_verified_user)): file_item = FileModelResponse( **{ **file_item.model_dump(), - "error": e, + "error": str(e.detail) if hasattr(e, "detail") else str(e), } ) diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index 49a08176b..6dd6ff258 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -133,6 +133,10 @@ const uploadedFile = await uploadFile(localStorage.token, file); if (uploadedFile) { + if (uploadedFile.error) { + toast.warning(uploadedFile.error); + } + fileItem.status = 'uploaded'; fileItem.file = uploadedFile; fileItem.id = uploadedFile.id;