refac: DOCS_DIR deprecated

This commit is contained in:
Timothy J. Baek 2024-10-05 01:45:22 -07:00
parent ed3e1397ca
commit 0bd88090bb
3 changed files with 1 additions and 58 deletions

View File

@ -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,

View File

@ -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
############################

View File

@ -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
####################################