diff --git a/backend/open_webui/apps/webui/routers/utils.py b/backend/open_webui/apps/webui/routers/utils.py index 731f98784..bb556b318 100644 --- a/backend/open_webui/apps/webui/routers/utils.py +++ b/backend/open_webui/apps/webui/routers/utils.py @@ -4,6 +4,7 @@ from pathlib import Path import black import markdown from open_webui.config import DATA_DIR, ENABLE_ADMIN_EXPORT +from open_webui.env import FONTS_DIR from open_webui.constants import ERROR_MESSAGES from fastapi import APIRouter, Depends, HTTPException, Response, status from fpdf import FPDF @@ -57,14 +58,10 @@ class ChatForm(BaseModel): async def download_chat_as_pdf( form_data: ChatForm, ): + global FONTS_DIR pdf = FPDF() pdf.add_page() - # When running in docker, workdir is /app/backend, so fonts is in /app/backend/static/fonts - FONTS_DIR = Path("./static/fonts") - - # Non Docker Installation - # When running using `pip install` the static directory is in the site packages. if not FONTS_DIR.exists(): FONTS_DIR = Path(site.getsitepackages()[0]) / "static/fonts" diff --git a/backend/open_webui/env.py b/backend/open_webui/env.py index 865d61003..b716769c2 100644 --- a/backend/open_webui/env.py +++ b/backend/open_webui/env.py @@ -198,6 +198,8 @@ if FROM_INIT_PY: DATA_DIR = Path(os.getenv("DATA_DIR", OPEN_WEBUI_DIR / "data")) +FONTS_DIR = Path(os.getenv("FONTS_DIR", OPEN_WEBUI_DIR / "static" / "fonts")) + FRONTEND_BUILD_DIR = Path(os.getenv("FRONTEND_BUILD_DIR", BASE_DIR / "build")).resolve() if FROM_INIT_PY: