diff --git a/backend/open_webui/apps/webui/routers/files.py b/backend/open_webui/apps/webui/routers/files.py index 70d58cc40..a4062d142 100644 --- a/backend/open_webui/apps/webui/routers/files.py +++ b/backend/open_webui/apps/webui/routers/files.py @@ -92,6 +92,7 @@ def upload_file(file: UploadFile = File(...), user=Depends(get_verified_user)): @router.post("/upload/dir") def upload_dir(user=Depends(get_admin_user)): + file_ids = [] for path in Path(DOCS_DIR).rglob("./**/*"): if path.is_file() and not path.name.startswith("."): try: @@ -126,13 +127,14 @@ def upload_dir(user=Depends(get_admin_user)): try: process_file(ProcessFileForm(file_id=id)) log.debug(f"File processed: {path}, {file.id}") + file_ids.append(file.id) except Exception as e: log.exception(e) log.error(f"Error processing file: {file.id}") except Exception as e: log.exception(e) pass - return True + return file_ids ############################ diff --git a/backend/open_webui/apps/webui/routers/knowledge.py b/backend/open_webui/apps/webui/routers/knowledge.py index 203ec95c7..4a73f1528 100644 --- a/backend/open_webui/apps/webui/routers/knowledge.py +++ b/backend/open_webui/apps/webui/routers/knowledge.py @@ -160,6 +160,10 @@ def add_file_to_knowledge_by_id( process_file(ProcessFileForm(file_id=form_data.file_id, collection_name=id)) except Exception as e: log.debug(e) + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=str(e), + ) if knowledge: data = knowledge.data or {} diff --git a/src/lib/components/admin/Settings/Documents.svelte b/src/lib/components/admin/Settings/Documents.svelte index 5c44938f7..d6f7dc987 100644 --- a/src/lib/components/admin/Settings/Documents.svelte +++ b/src/lib/components/admin/Settings/Documents.svelte @@ -62,16 +62,6 @@ hybrid: false }; - const scanHandler = async () => { - scanDirLoading = true; - const res = await uploadDir(localStorage.token); - scanDirLoading = false; - - if (res) { - toast.success($i18n.t('Scan complete!')); - } - }; - const embeddingModelUpdateHandler = async () => { if (embeddingEngine === '' && embeddingModel.split('/').length - 1 > 1) { toast.error( @@ -284,58 +274,6 @@