diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index ed73e7d83..349c35ce5 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -699,16 +699,16 @@ AZURE_STORAGE_KEY = os.environ.get("AZURE_STORAGE_KEY", None) # File Upload DIR #################################### -UPLOAD_DIR = f"{DATA_DIR}/uploads" -Path(UPLOAD_DIR).mkdir(parents=True, exist_ok=True) +UPLOAD_DIR = DATA_DIR / "uploads" +UPLOAD_DIR.mkdir(parents=True, exist_ok=True) #################################### # Cache DIR #################################### -CACHE_DIR = f"{DATA_DIR}/cache" -Path(CACHE_DIR).mkdir(parents=True, exist_ok=True) +CACHE_DIR = DATA_DIR / "cache" +CACHE_DIR.mkdir(parents=True, exist_ok=True) #################################### diff --git a/backend/open_webui/routers/audio.py b/backend/open_webui/routers/audio.py index c949e65a4..d6f74eac4 100644 --- a/backend/open_webui/routers/audio.py +++ b/backend/open_webui/routers/audio.py @@ -54,7 +54,7 @@ MAX_FILE_SIZE = MAX_FILE_SIZE_MB * 1024 * 1024 # Convert MB to bytes log = logging.getLogger(__name__) log.setLevel(SRC_LOG_LEVELS["AUDIO"]) -SPEECH_CACHE_DIR = Path(CACHE_DIR).joinpath("./audio/speech/") +SPEECH_CACHE_DIR = CACHE_DIR / "audio" / "speech" SPEECH_CACHE_DIR.mkdir(parents=True, exist_ok=True) diff --git a/backend/open_webui/routers/functions.py b/backend/open_webui/routers/functions.py index ac2db9322..206610138 100644 --- a/backend/open_webui/routers/functions.py +++ b/backend/open_webui/routers/functions.py @@ -74,7 +74,7 @@ async def create_new_function( function = Functions.insert_new_function(user.id, function_type, form_data) - function_cache_dir = Path(CACHE_DIR) / "functions" / form_data.id + function_cache_dir = CACHE_DIR / "functions" / form_data.id function_cache_dir.mkdir(parents=True, exist_ok=True) if function: diff --git a/backend/open_webui/routers/images.py b/backend/open_webui/routers/images.py index f8be93719..c51d2f996 100644 --- a/backend/open_webui/routers/images.py +++ b/backend/open_webui/routers/images.py @@ -25,7 +25,7 @@ from pydantic import BaseModel log = logging.getLogger(__name__) log.setLevel(SRC_LOG_LEVELS["IMAGES"]) -IMAGE_CACHE_DIR = Path(CACHE_DIR).joinpath("./image/generations/") +IMAGE_CACHE_DIR = CACHE_DIR / "image" / "generations" IMAGE_CACHE_DIR.mkdir(parents=True, exist_ok=True) diff --git a/backend/open_webui/routers/openai.py b/backend/open_webui/routers/openai.py index 470deb0a5..73b182d3c 100644 --- a/backend/open_webui/routers/openai.py +++ b/backend/open_webui/routers/openai.py @@ -192,7 +192,7 @@ async def speech(request: Request, user=Depends(get_verified_user)): body = await request.body() name = hashlib.sha256(body).hexdigest() - SPEECH_CACHE_DIR = Path(CACHE_DIR).joinpath("./audio/speech/") + SPEECH_CACHE_DIR = CACHE_DIR / "audio" / "speech" SPEECH_CACHE_DIR.mkdir(parents=True, exist_ok=True) file_path = SPEECH_CACHE_DIR.joinpath(f"{name}.mp3") file_body_path = SPEECH_CACHE_DIR.joinpath(f"{name}.json") diff --git a/backend/open_webui/routers/tools.py b/backend/open_webui/routers/tools.py index 5e4109037..211264cde 100644 --- a/backend/open_webui/routers/tools.py +++ b/backend/open_webui/routers/tools.py @@ -105,7 +105,7 @@ async def create_new_tools( specs = get_tools_specs(TOOLS[form_data.id]) tools = Tools.insert_new_tool(user.id, form_data, specs) - tool_cache_dir = Path(CACHE_DIR) / "tools" / form_data.id + tool_cache_dir = CACHE_DIR / "tools" / form_data.id tool_cache_dir.mkdir(parents=True, exist_ok=True) if tools: diff --git a/backend/open_webui/utils/pdf_generator.py b/backend/open_webui/utils/pdf_generator.py index 8b04dd81b..c137b49da 100644 --- a/backend/open_webui/utils/pdf_generator.py +++ b/backend/open_webui/utils/pdf_generator.py @@ -110,7 +110,7 @@ class PDFGenerator: # When running using `pip install -e .` the static directory is in the site packages. # This path only works if `open-webui serve` is run from the root of this project. if not FONTS_DIR.exists(): - FONTS_DIR = Path("./backend/static/fonts") + FONTS_DIR = Path(".") / "backend" / "static" / "fonts" pdf.add_font("NotoSans", "", f"{FONTS_DIR}/NotoSans-Regular.ttf") pdf.add_font("NotoSans", "b", f"{FONTS_DIR}/NotoSans-Bold.ttf")