diff --git a/backend/open_webui/apps/retrieval/main.py b/backend/open_webui/apps/retrieval/main.py index 801760a65..7ad4af064 100644 --- a/backend/open_webui/apps/retrieval/main.py +++ b/backend/open_webui/apps/retrieval/main.py @@ -873,7 +873,7 @@ def save_docs_to_vector_db( return True except Exception as e: log.exception(e) - return False + raise e class ProcessFileForm(BaseModel): @@ -903,7 +903,7 @@ def process_file( docs = [ Document( - page_content=form_data.content, + page_content=form_data.content.replace("
", "\n"), metadata={ **file.meta, "name": file.filename, diff --git a/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte b/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte index 53c198150..cabcff571 100644 --- a/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte +++ b/src/lib/components/workspace/Knowledge/KnowledgeBase.svelte @@ -446,7 +446,13 @@ const onDragOver = (e) => { e.preventDefault(); - dragged = true; + + // Check if a file is being draggedOver. + if (e.dataTransfer?.types?.includes('Files')) { + dragged = true; + } else { + dragged = false; + } }; const onDragLeave = () => { @@ -457,15 +463,17 @@ e.preventDefault(); dragged = false; - if (e.dataTransfer?.files) { - const inputFiles = e.dataTransfer?.files; + if (e.dataTransfer?.types?.includes('Files')) { + if (e.dataTransfer?.files) { + const inputFiles = e.dataTransfer?.files; - if (inputFiles && inputFiles.length > 0) { - for (const file of inputFiles) { - await uploadFileHandler(file); + if (inputFiles && inputFiles.length > 0) { + for (const file of inputFiles) { + await uploadFileHandler(file); + } + } else { + toast.error($i18n.t(`File not found.`)); } - } else { - toast.error($i18n.t(`File not found.`)); } } };