diff --git a/backend/config.py b/backend/config.py index d7c9414f..f630fa94 100644 --- a/backend/config.py +++ b/backend/config.py @@ -1,13 +1,17 @@ import os import chromadb from chromadb import Settings -from secrets import token_bytes from base64 import b64encode -from constants import ERROR_MESSAGES +from bs4 import BeautifulSoup + from pathlib import Path import json import markdown -from bs4 import BeautifulSoup +import requests +import shutil + +from secrets import token_bytes +from constants import ERROR_MESSAGES try: @@ -17,6 +21,8 @@ try: except ImportError: print("dotenv not installed, skipping...") +WEBUI_NAME = "Open WebUI" + #################################### # ENV (dev,test,prod) @@ -24,7 +30,6 @@ except ImportError: ENV = os.environ.get("ENV", "dev") - try: with open(f"../package.json", "r") as f: PACKAGE_DATA = json.load(f) @@ -94,6 +99,32 @@ for version in soup.find_all("h2"): CHANGELOG = changelog_json + +#################################### +# CUSTOM_NAME +#################################### + +CUSTOM_NAME = os.environ.get("CUSTOM_NAME", "") +if CUSTOM_NAME: + r = requests.get(f"https://api.openwebui.com/api/v1/custom/{CUSTOM_NAME}") + data = r.json() + + if "logo" in data: + url = ( + f"https://api.openwebui.com{data['logo']}" + if data["logo"][0] == "/" + else data["logo"] + ) + + r = requests.get(url, stream=True) + if r.status_code == 200: + with open("./static/favicon.png", "wb") as f: + r.raw.decode_content = True + shutil.copyfileobj(r.raw, f) + + WEBUI_NAME = data["name"] + + #################################### # DATA/FRONTEND BUILD DIR #################################### diff --git a/backend/main.py b/backend/main.py index 8a9b9dce..0be56752 100644 --- a/backend/main.py +++ b/backend/main.py @@ -20,7 +20,7 @@ from apps.rag.main import app as rag_app from apps.web.main import app as webui_app -from config import ENV, VERSION, CHANGELOG, FRONTEND_BUILD_DIR +from config import WEBUI_NAME, ENV, VERSION, CHANGELOG, FRONTEND_BUILD_DIR class SPAStaticFiles(StaticFiles): @@ -72,6 +72,7 @@ async def get_app_config(): return { "status": True, + "name": WEBUI_NAME, "version": VERSION, "images": images_app.state.ENABLED, "default_models": webui_app.state.DEFAULT_MODELS, @@ -84,6 +85,9 @@ async def get_app_changelog(): return CHANGELOG +app.mount("/static", StaticFiles(directory="static"), name="static") + + app.mount( "/", SPAStaticFiles(directory=FRONTEND_BUILD_DIR, html=True), diff --git a/backend/static/favicon.png b/backend/static/favicon.png new file mode 100644 index 00000000..519af1db Binary files /dev/null and b/backend/static/favicon.png differ diff --git a/src/lib/components/ChangelogModal.svelte b/src/lib/components/ChangelogModal.svelte index 00c12a39..0cf1f006 100644 --- a/src/lib/components/ChangelogModal.svelte +++ b/src/lib/components/ChangelogModal.svelte @@ -2,9 +2,9 @@ import { onMount } from 'svelte'; import { Confetti } from 'svelte-confetti'; - import { config } from '$lib/stores'; + import { WEBUI_NAME, config } from '$lib/stores'; - import { WEBUI_NAME, WEB_UI_VERSION } from '$lib/constants'; + import { WEBUI_VERSION } from '$lib/constants'; import { getChangelog } from '$lib/apis'; import Modal from './common/Modal.svelte'; @@ -23,7 +23,7 @@
- What’s New in {WEBUI_NAME} + What’s New in {$WEBUI_NAME}
- v{WEB_UI_VERSION} + v{WEBUI_VERSION}
diff --git a/src/lib/components/chat/Messages/Placeholder.svelte b/src/lib/components/chat/Messages/Placeholder.svelte index ae9ced14..f1f3e80a 100644 --- a/src/lib/components/chat/Messages/Placeholder.svelte +++ b/src/lib/components/chat/Messages/Placeholder.svelte @@ -1,4 +1,5 @@ - {WEBUI_NAME} + {$WEBUI_NAME} + diff --git a/src/routes/auth/+page.svelte b/src/routes/auth/+page.svelte index 05891d4f..30c5a93e 100644 --- a/src/routes/auth/+page.svelte +++ b/src/routes/auth/+page.svelte @@ -1,8 +1,8 @@