diff --git a/backend/apps/web/routers/utils.py b/backend/apps/web/routers/utils.py index 0bb3ea3c..9adf2801 100644 --- a/backend/apps/web/routers/utils.py +++ b/backend/apps/web/routers/utils.py @@ -111,12 +111,12 @@ def upload(file: UploadFile = File(...)): file_path = f"{UPLOAD_DIR}/{file.filename}" # Save file in chunks - with file_path.open("wb+") as f: + with open(file_path, "wb+") as f: for chunk in file.file: f.write(chunk) def file_process_stream(): - total_size = os.path.getsize(str(file_path)) + total_size = os.path.getsize(file_path) chunk_size = 1024 * 1024 try: with open(file_path, "rb") as f: diff --git a/backend/config.py b/backend/config.py index 59ef1947..169baa69 100644 --- a/backend/config.py +++ b/backend/config.py @@ -25,12 +25,13 @@ except ImportError: # File Upload #################################### -DATA_DIR = Path(os.getenv("DATA_DIR", "./data")).resolve() +DATA_DIR = str(Path(os.getenv("DATA_DIR", "./data")).resolve()) UPLOAD_DIR = f"{DATA_DIR}/uploads" -UPLOAD_DIR.mkdir(parents=True, exist_ok=True) -FRONTEND_BUILD_DIR = Path(os.getenv("FRONTEND_BUILD_DIR", "../build")) +Path(UPLOAD_DIR).mkdir(parents=True, exist_ok=True) + +FRONTEND_BUILD_DIR = str(Path(os.getenv("FRONTEND_BUILD_DIR", "../build"))) #################################### # ENV (dev,test,prod) @@ -88,7 +89,7 @@ if WEBUI_AUTH and WEBUI_JWT_SECRET_KEY == "": CHROMA_DATA_PATH = f"{DATA_DIR}/vector_db" EMBED_MODEL = "all-MiniLM-L6-v2" CHROMA_CLIENT = chromadb.PersistentClient( - path=str(CHROMA_DATA_PATH), settings=Settings(allow_reset=True) + path=CHROMA_DATA_PATH, settings=Settings(allow_reset=True) ) CHUNK_SIZE = 1500 CHUNK_OVERLAP = 100 diff --git a/backend/main.py b/backend/main.py index a0ad73fd..f7a82b66 100644 --- a/backend/main.py +++ b/backend/main.py @@ -60,6 +60,6 @@ app.mount("/rag/api/v1", rag_app) app.mount( "/", - SPAStaticFiles(directory=str(FRONTEND_BUILD_DIR), html=True), + SPAStaticFiles(directory=FRONTEND_BUILD_DIR, html=True), name="spa-static-files", )