From 0bd88090bb926891c065c735c2c35eab8c3f8a30 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sat, 5 Oct 2024 01:45:22 -0700 Subject: [PATCH] refac: DOCS_DIR deprecated --- backend/open_webui/apps/retrieval/main.py | 1 - .../open_webui/apps/webui/routers/files.py | 49 +------------------ backend/open_webui/config.py | 9 ---- 3 files changed, 1 insertion(+), 58 deletions(-) diff --git a/backend/open_webui/apps/retrieval/main.py b/backend/open_webui/apps/retrieval/main.py index ec22b318c..fe891a8ac 100644 --- a/backend/open_webui/apps/retrieval/main.py +++ b/backend/open_webui/apps/retrieval/main.py @@ -51,7 +51,6 @@ from open_webui.config import ( CHUNK_SIZE, CONTENT_EXTRACTION_ENGINE, CORS_ALLOW_ORIGIN, - DOCS_DIR, ENABLE_RAG_HYBRID_SEARCH, ENABLE_RAG_LOCAL_WEB_FETCH, ENABLE_RAG_WEB_LOADER_SSL_VERIFICATION, diff --git a/backend/open_webui/apps/webui/routers/files.py b/backend/open_webui/apps/webui/routers/files.py index a4062d142..0679ae062 100644 --- a/backend/open_webui/apps/webui/routers/files.py +++ b/backend/open_webui/apps/webui/routers/files.py @@ -11,7 +11,7 @@ import mimetypes from open_webui.apps.webui.models.files import FileForm, FileModel, Files from open_webui.apps.retrieval.main import process_file, ProcessFileForm -from open_webui.config import UPLOAD_DIR, DOCS_DIR +from open_webui.config import UPLOAD_DIR from open_webui.env import SRC_LOG_LEVELS from open_webui.constants import ERROR_MESSAGES @@ -90,53 +90,6 @@ 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: - log.debug(f"Processing file from path: {path}") - - filename = path.name - file_content_type = mimetypes.guess_type(path) - - # replace filename with uuid - id = str(uuid.uuid4()) - name = filename - - contents = path.read_bytes() - file_path = str(path) - - file = Files.insert_new_file( - user.id, - FileForm( - **{ - "id": id, - "filename": filename, - "meta": { - "name": name, - "content_type": file_content_type, - "size": len(contents), - "path": file_path, - }, - } - ), - ) - - 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 file_ids - - ############################ # List Files ############################ diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index bd02c917c..a4ecb33ee 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -518,15 +518,6 @@ Path(UPLOAD_DIR).mkdir(parents=True, exist_ok=True) CACHE_DIR = f"{DATA_DIR}/cache" Path(CACHE_DIR).mkdir(parents=True, exist_ok=True) - -#################################### -# Docs DIR -#################################### - -DOCS_DIR = os.getenv("DOCS_DIR", f"{DATA_DIR}/docs") -Path(DOCS_DIR).mkdir(parents=True, exist_ok=True) - - #################################### # Tools DIR ####################################