feat:精简
Some checks failed
Create and publish Docker images with specific build args / build-main-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-main-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda126-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda126-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-slim-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-slim-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Python CI / Format Backend (3.11.x) (push) Has been cancelled
Python CI / Format Backend (3.12.x) (push) Has been cancelled
Frontend Build / Format & Build Frontend (push) Has been cancelled
Frontend Build / Frontend Unit Tests (push) Has been cancelled
Create and publish Docker images with specific build args / merge-main-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-cuda-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-cuda126-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-ollama-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-slim-images (push) Has been cancelled
Close inactive issues / close-issues (push) Has been cancelled

This commit is contained in:
2026-01-16 18:34:38 +08:00
parent 16263710d9
commit 11fcec9387
137 changed files with 68993 additions and 6435 deletions

View File

@@ -50,7 +50,7 @@ from starsessions.stores.redis import RedisStore
from open_webui.utils import logger
from open_webui.utils.audit import AuditLevel, AuditLoggingMiddleware
from open_webui.utils.subscription.check import check_subscription_access, record_usage
from open_webui.utils.subscription.check import check_subscription_access
from open_webui.utils.logger import start_logger
from open_webui.socket.main import (
MODELS,
@@ -70,7 +70,6 @@ from open_webui.routers import (
auths,
channels,
chats,
notes,
folders,
configs,
groups,
@@ -348,7 +347,6 @@ from open_webui.config import (
API_KEYS_ALLOWED_ENDPOINTS,
ENABLE_FOLDERS,
ENABLE_CHANNELS,
ENABLE_NOTES,
ENABLE_COMMUNITY_SHARING,
ENABLE_MESSAGE_RATING,
ENABLE_USER_WEBHOOKS,
@@ -455,6 +453,20 @@ from open_webui.config import (
ALIPAY_SERVER_URL,
ALIPAY_PRODUCT_CODE,
ALIPAY_CALLBACK_HOST,
# Branding
BRANDING_ORGANIZATION_NAME,
BRANDING_CUSTOM_NAME,
BRANDING_FAVICON_ICO,
BRANDING_FAVICON_PNG,
BRANDING_FAVICON_DARK_PNG,
BRANDING_FAVICON_SVG,
BRANDING_AUTH_LOGO_URL,
BRANDING_SIDEBAR_LOGO_URL,
# Email Templates
EMAIL_VERIFY_TEMPLATE,
EMAIL_CODE_TEMPLATE,
DEFAULT_EMAIL_VERIFY_TEMPLATE,
DEFAULT_EMAIL_CODE_TEMPLATE,
)
from open_webui.env import (
ENABLE_CUSTOM_MODEL_FALLBACK,
@@ -514,6 +526,7 @@ from open_webui.utils.access_control import has_access
from open_webui.utils.auth import (
get_license_data,
apply_branding,
get_http_authorization_cred,
decode_token,
get_admin_user,
@@ -596,6 +609,9 @@ async def lifespan(app: FastAPI):
if LICENSE_KEY:
get_license_data(app, LICENSE_KEY)
# Apply branding settings from database config
apply_branding(app)
# This should be blocking (sync) so functions are not deactivated on first /get_models calls
# when the first user lands on the / route.
log.info("Installing external dependencies of functions and tools...")
@@ -798,7 +814,6 @@ app.state.config.BANNERS = WEBUI_BANNERS
app.state.config.ENABLE_FOLDERS = ENABLE_FOLDERS
app.state.config.ENABLE_CHANNELS = ENABLE_CHANNELS
app.state.config.ENABLE_NOTES = ENABLE_NOTES
app.state.config.ENABLE_COMMUNITY_SHARING = ENABLE_COMMUNITY_SHARING
app.state.config.ENABLE_MESSAGE_RATING = ENABLE_MESSAGE_RATING
app.state.config.ENABLE_USER_WEBHOOKS = ENABLE_USER_WEBHOOKS
@@ -835,6 +850,20 @@ app.state.config.ENABLE_LDAP_GROUP_MANAGEMENT = ENABLE_LDAP_GROUP_MANAGEMENT
app.state.config.ENABLE_LDAP_GROUP_CREATION = ENABLE_LDAP_GROUP_CREATION
app.state.config.LDAP_ATTRIBUTE_FOR_GROUPS = LDAP_ATTRIBUTE_FOR_GROUPS
# Branding Config
app.state.config.BRANDING_ORGANIZATION_NAME = BRANDING_ORGANIZATION_NAME
app.state.config.BRANDING_CUSTOM_NAME = BRANDING_CUSTOM_NAME
app.state.config.BRANDING_FAVICON_ICO = BRANDING_FAVICON_ICO
app.state.config.BRANDING_FAVICON_PNG = BRANDING_FAVICON_PNG
app.state.config.BRANDING_FAVICON_DARK_PNG = BRANDING_FAVICON_DARK_PNG
app.state.config.BRANDING_FAVICON_SVG = BRANDING_FAVICON_SVG
app.state.config.BRANDING_AUTH_LOGO_URL = BRANDING_AUTH_LOGO_URL
app.state.config.BRANDING_SIDEBAR_LOGO_URL = BRANDING_SIDEBAR_LOGO_URL
# Email Templates Config
app.state.config.EMAIL_VERIFY_TEMPLATE = EMAIL_VERIFY_TEMPLATE
app.state.config.EMAIL_CODE_TEMPLATE = EMAIL_CODE_TEMPLATE
app.state.AUTH_TRUSTED_EMAIL_HEADER = WEBUI_AUTH_TRUSTED_EMAIL_HEADER
app.state.AUTH_TRUSTED_NAME_HEADER = WEBUI_AUTH_TRUSTED_NAME_HEADER
@@ -1439,7 +1468,6 @@ app.include_router(subscription.router, prefix="/api/v1/subscription", tags=["su
app.include_router(channels.router, prefix="/api/v1/channels", tags=["channels"])
app.include_router(chats.router, prefix="/api/v1/chats", tags=["chats"])
app.include_router(notes.router, prefix="/api/v1/notes", tags=["notes"])
app.include_router(models.router, prefix="/api/v1/models", tags=["models"])
@@ -1765,13 +1793,6 @@ async def chat_completion(
"model": model_id,
},
)
# record subscription usage
record_usage(
user_id=user.id,
model_id=model_id,
chat_id=metadata["chat_id"],
message_id=metadata["message_id"],
)
except:
pass
@@ -1956,12 +1977,30 @@ async def get_app_config(request: Request):
if user is None:
onboarding = user_count == 0
def get_config_value(config_obj, default=""):
if hasattr(config_obj, "value"):
return config_obj.value or default
return config_obj or default
auth_logo_url = get_config_value(app.state.config.BRANDING_AUTH_LOGO_URL)
if not auth_logo_url:
auth_logo_url = (
get_config_value(app.state.config.BRANDING_FAVICON_PNG)
or get_config_value(app.state.config.BRANDING_FAVICON_SVG)
or get_config_value(app.state.config.BRANDING_FAVICON_ICO)
)
return {
**({"onboarding": True} if onboarding else {}),
"status": True,
"name": app.state.WEBUI_NAME,
"version": VERSION,
"default_locale": str(DEFAULT_LOCALE),
"branding": {
"auth_logo_url": auth_logo_url,
"sidebar_logo_url": get_config_value(app.state.config.BRANDING_SIDEBAR_LOGO_URL),
"auth_logo_link_url": get_config_value(app.state.config.BRANDING_AUTH_LOGO_LINK_URL),
},
"oauth": {
"providers": {
name: config.get("name", name)
@@ -1985,7 +2024,6 @@ async def get_app_config(request: Request):
"enable_direct_connections": app.state.config.ENABLE_DIRECT_CONNECTIONS,
"enable_folders": app.state.config.ENABLE_FOLDERS,
"enable_channels": app.state.config.ENABLE_CHANNELS,
"enable_notes": app.state.config.ENABLE_NOTES,
"enable_web_search": app.state.config.ENABLE_WEB_SEARCH,
"enable_code_execution": app.state.config.ENABLE_CODE_EXECUTION,
"enable_code_interpreter": app.state.config.ENABLE_CODE_INTERPRETER,