From 508de20779168003e538bb936b49a31d4a8fb8bb Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sun, 6 Sep 2026 17:27:30 -0400 Subject: [PATCH] refac --- backend/open_webui/env.py | 2 - backend/open_webui/models/chats.py | 5 - backend/open_webui/routers/utils.py | 24 +- .../open_webui/static/assets/pdf-style.css | 295 ------------------ .../open_webui/static/fonts/NotoSans-Bold.ttf | Bin 582604 -> 0 bytes .../static/fonts/NotoSans-Italic.ttf | Bin 597000 -> 0 bytes .../static/fonts/NotoSans-Regular.ttf | Bin 582748 -> 0 bytes .../static/fonts/NotoSansJP-Regular.ttf | Bin 5732824 -> 0 bytes .../static/fonts/NotoSansKR-Regular.ttf | Bin 6192764 -> 0 bytes .../static/fonts/NotoSansSC-Regular.ttf | Bin 10560616 -> 0 bytes backend/open_webui/static/fonts/Twemoji.ttf | Bin 1496648 -> 0 bytes backend/open_webui/utils/pdf_generator.py | 140 --------- backend/requirements-slim.txt | 1 - backend/requirements.txt | 1 - pyproject.toml | 1 - src/lib/apis/utils/index.ts | 27 -- src/lib/components/layout/Navbar/Menu.svelte | 1 - .../components/layout/Sidebar/ChatMenu.svelte | 1 - uv.lock | 85 ++--- 19 files changed, 23 insertions(+), 560 deletions(-) delete mode 100644 backend/open_webui/static/assets/pdf-style.css delete mode 100644 backend/open_webui/static/fonts/NotoSans-Bold.ttf delete mode 100644 backend/open_webui/static/fonts/NotoSans-Italic.ttf delete mode 100644 backend/open_webui/static/fonts/NotoSans-Regular.ttf delete mode 100644 backend/open_webui/static/fonts/NotoSansJP-Regular.ttf delete mode 100644 backend/open_webui/static/fonts/NotoSansKR-Regular.ttf delete mode 100644 backend/open_webui/static/fonts/NotoSansSC-Regular.ttf delete mode 100644 backend/open_webui/static/fonts/Twemoji.ttf delete mode 100644 backend/open_webui/utils/pdf_generator.py diff --git a/backend/open_webui/env.py b/backend/open_webui/env.py index 7380f3eb3e..3d2cabdf18 100644 --- a/backend/open_webui/env.py +++ b/backend/open_webui/env.py @@ -251,8 +251,6 @@ if FROM_INIT_PY: STATIC_DIR = Path(os.getenv('STATIC_DIR', OPEN_WEBUI_DIR / 'static')) -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: diff --git a/backend/open_webui/models/chats.py b/backend/open_webui/models/chats.py index fc972cb4bc..508b0d0b4e 100644 --- a/backend/open_webui/models/chats.py +++ b/backend/open_webui/models/chats.py @@ -267,11 +267,6 @@ class ChatsImportForm(BaseModel): chats: list[ChatImportForm] -class ChatTitleMessagesForm(BaseModel): - title: str - messages: list[dict] - - class ChatTitleForm(BaseModel): title: str diff --git a/backend/open_webui/routers/utils.py b/backend/open_webui/routers/utils.py index dcad54f4b1..48e9cc3e5c 100644 --- a/backend/open_webui/routers/utils.py +++ b/backend/open_webui/routers/utils.py @@ -3,15 +3,13 @@ from __future__ import annotations import logging import black -from fastapi import APIRouter, Depends, HTTPException, Request, Response, status +from fastapi import APIRouter, Depends, HTTPException, Request, status from open_webui.config import DATA_DIR, ENABLE_ADMIN_EXPORT from open_webui.constants import ERROR_MESSAGES -from open_webui.models.chats import ChatTitleMessagesForm from open_webui.models.config import Config from open_webui.utils.auth import get_admin_user, get_verified_user from open_webui.utils.code_interpreter import execute_code_jupyter from open_webui.utils.misc import get_gravatar_url -from open_webui.utils.pdf_generator import PDFGenerator from pydantic import BaseModel from starlette.responses import FileResponse @@ -73,26 +71,6 @@ async def execute_code(request: Request, form_data: CodeForm, user=Depends(get_v ) -class ChatForm(BaseModel): - title: str - messages: list[dict] - - -@router.post('/pdf') -async def download_chat_as_pdf(form_data: ChatTitleMessagesForm, user=Depends(get_verified_user)): - try: - pdf_bytes = PDFGenerator(form_data).generate_chat_pdf() - - return Response( - content=pdf_bytes, - media_type='application/pdf', - headers={'Content-Disposition': 'attachment;filename=chat.pdf'}, - ) - except Exception as e: - log.exception(f'Error generating PDF: {e}') - raise HTTPException(status_code=400, detail=str(e)) - - @router.get('/db/download') async def download_db(user=Depends(get_admin_user)): """Download the raw SQLite database file (admin-only, SQLite deployments only).""" diff --git a/backend/open_webui/static/assets/pdf-style.css b/backend/open_webui/static/assets/pdf-style.css deleted file mode 100644 index 68c10b9d1a..0000000000 --- a/backend/open_webui/static/assets/pdf-style.css +++ /dev/null @@ -1,295 +0,0 @@ -/* HTML and Body */ -@font-face { - font-family: 'NotoSansSC-Regular'; - src: url('fonts/NotoSansSC-Regular.ttf'); -} - -html { - font-family: - -apple-system, BlinkMacSystemFont, 'Segoe UI', 'NotoSans', 'NotoSansJP', 'NotoSansKR', - 'NotoSansSC', 'Twemoji', 'STSong-Light', 'MSung-Light', 'HeiseiMin-W3', 'HYSMyeongJo-Medium', - Roboto, 'Helvetica Neue', Arial, sans-serif; - font-size: 14px; /* Default font size */ - line-height: 1.5; -} - -*, -*::before, -*::after { - box-sizing: inherit; -} - -body { - margin: 0; - padding: 0; - background-color: #fff; - width: auto; -} - -/* Typography */ -h1, -h2, -h3, -h4, -h5, -h6 { - font-weight: 500; - margin: 0; -} - -h1 { - font-size: 2.5rem; -} - -h2 { - font-size: 2rem; -} - -h3 { - font-size: 1.75rem; -} - -h4 { - font-size: 1.5rem; -} - -h5 { - font-size: 1.25rem; -} - -h6 { - font-size: 1rem; -} - -p { - margin-top: 0; - margin-bottom: 1rem; -} - -/* Grid System */ -.container { - width: 100%; - padding-right: 15px; - padding-left: 15px; - margin-right: auto; - margin-left: auto; -} - -/* Utilities */ -.text-center { - text-align: center; -} - -/* Additional Text Utilities */ -.text-muted { - color: #6c757d; /* Muted text color */ -} - -/* Small Text */ -small { - font-size: 80%; /* Smaller font size relative to the base */ - color: #6c757d; /* Lighter text color for secondary information */ - margin-bottom: 0; - margin-top: 0; -} - -/* Strong Element Styles */ -strong { - font-weight: bolder; /* Ensures the text is bold */ - color: inherit; /* Inherits the color from its parent element */ -} - -/* link */ -a { - color: #007bff; - text-decoration: none; - background-color: transparent; -} - -a:hover { - color: #0056b3; - text-decoration: underline; -} - -/* General styles for lists */ -ol, -ul, -li { - padding-left: 40px; /* Increase padding to move bullet points to the right */ - margin-left: 20px; /* Indent lists from the left */ -} - -/* Ordered list styles */ -ol { - list-style-type: decimal; /* Use numbers for ordered lists */ - margin-bottom: 10px; /* Space after each list */ -} - -ol li { - margin-bottom: 0.5rem; /* Space between ordered list items */ -} - -/* Unordered list styles */ -ul { - list-style-type: disc; /* Use bullets for unordered lists */ - margin-bottom: 10px; /* Space after each list */ -} - -ul li { - margin-bottom: 0.5rem; /* Space between unordered list items */ -} - -/* List item styles */ -li { - margin-bottom: 5px; /* Space between list items */ - line-height: 1.5; /* Line height for better readability */ -} - -/* Nested lists */ -ol ol, -ol ul, -ul ol, -ul ul { - padding-left: 20px; - margin-left: 30px; /* Further indent nested lists */ - margin-bottom: 0; /* Remove extra margin at the bottom of nested lists */ -} - -/* Code blocks */ -pre { - background-color: #f4f4f4; - padding: 10px; - overflow-x: auto; - max-width: 100%; /* Ensure it doesn't overflow the page */ - width: 80%; /* Set a specific width for a container-like appearance */ - margin: 0 1em; /* Center the pre block */ - box-sizing: border-box; /* Include padding in the width */ - border: 1px solid #ccc; /* Optional: Add a border for better definition */ - border-radius: 4px; /* Optional: Add rounded corners */ -} - -code { - font-family: 'Courier New', Courier, monospace; - background-color: #f4f4f4; - padding: 2px 4px; - border-radius: 4px; - box-sizing: border-box; /* Include padding in the width */ -} - -.message { - margin-top: 8px; - margin-bottom: 8px; - max-width: 100%; - overflow-wrap: break-word; -} - -/* Table Styles */ -table { - width: 100%; - margin-bottom: 1rem; - color: #212529; - border-collapse: collapse; /* Removes the space between borders */ -} - -th, -td { - margin: 0; - padding: 0.75rem; - vertical-align: top; - border-top: 1px solid #dee2e6; -} - -thead th { - vertical-align: bottom; - border-bottom: 2px solid #dee2e6; -} - -tbody + tbody { - border-top: 2px solid #dee2e6; -} - -/* markdown-section styles */ -.markdown-section blockquote, -.markdown-section h1, -.markdown-section h2, -.markdown-section h3, -.markdown-section h4, -.markdown-section h5, -.markdown-section h6, -.markdown-section p, -.markdown-section pre, -.markdown-section table, -.markdown-section ul { - /* Give most block elements margin top and bottom */ - margin-top: 1rem; -} - -/* Remove top margin if it's the first child */ -.markdown-section blockquote:first-child, -.markdown-section h1:first-child, -.markdown-section h2:first-child, -.markdown-section h3:first-child, -.markdown-section h4:first-child, -.markdown-section h5:first-child, -.markdown-section h6:first-child, -.markdown-section p:first-child, -.markdown-section pre:first-child, -.markdown-section table:first-child, -.markdown-section ul:first-child { - margin-top: 0; -} - -/* Remove top margin of