feat: sponsor custom name support

This commit is contained in:
Timothy J. Baek
2024-02-23 17:12:19 -08:00
parent fc330a1e8b
commit 62f67bed29
17 changed files with 94 additions and 44 deletions

View File

@@ -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
####################################