浏览代码

refac: DOCS_DIR deprecated

Timothy J. Baek 7 月之前
父节点
当前提交
0bd88090bb

+ 0 - 1
backend/open_webui/apps/retrieval/main.py

@@ -51,7 +51,6 @@ from open_webui.config import (
     CHUNK_SIZE,
     CHUNK_SIZE,
     CONTENT_EXTRACTION_ENGINE,
     CONTENT_EXTRACTION_ENGINE,
     CORS_ALLOW_ORIGIN,
     CORS_ALLOW_ORIGIN,
-    DOCS_DIR,
     ENABLE_RAG_HYBRID_SEARCH,
     ENABLE_RAG_HYBRID_SEARCH,
     ENABLE_RAG_LOCAL_WEB_FETCH,
     ENABLE_RAG_LOCAL_WEB_FETCH,
     ENABLE_RAG_WEB_LOADER_SSL_VERIFICATION,
     ENABLE_RAG_WEB_LOADER_SSL_VERIFICATION,

+ 1 - 48
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.webui.models.files import FileForm, FileModel, Files
 from open_webui.apps.retrieval.main import process_file, ProcessFileForm
 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.env import SRC_LOG_LEVELS
 from open_webui.constants import ERROR_MESSAGES
 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
 # List Files
 ############################
 ############################

+ 0 - 9
backend/open_webui/config.py

@@ -518,15 +518,6 @@ Path(UPLOAD_DIR).mkdir(parents=True, exist_ok=True)
 CACHE_DIR = f"{DATA_DIR}/cache"
 CACHE_DIR = f"{DATA_DIR}/cache"
 Path(CACHE_DIR).mkdir(parents=True, exist_ok=True)
 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
 # Tools DIR
 ####################################
 ####################################