forked from open-webui/open-webui
feat: sponsor custom name support
This commit is contained in:
parent
fc330a1e8b
commit
62f67bed29
17 changed files with 94 additions and 44 deletions
|
@ -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
|
||||
####################################
|
||||
|
|
|
@ -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),
|
||||
|
|
BIN
backend/static/favicon.png
Normal file
BIN
backend/static/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6 KiB |
Loading…
Add table
Add a link
Reference in a new issue