From 33f93371dc830607c800c7024d67f2cc5a641340 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sun, 30 Mar 2025 21:31:16 -0700 Subject: [PATCH] feat: user webhooks system settings --- backend/open_webui/config.py | 6 +++++ backend/open_webui/main.py | 3 +++ backend/open_webui/routers/auths.py | 9 +++++-- .../components/admin/Settings/General.svelte | 8 ++++++ .../components/chat/Settings/Account.svelte | 26 ++++++++++--------- 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index d8b7b98ed..f5f8135be 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -1092,6 +1092,12 @@ ENABLE_MESSAGE_RATING = PersistentConfig( os.environ.get("ENABLE_MESSAGE_RATING", "True").lower() == "true", ) +ENABLE_USER_WEBHOOKS = PersistentConfig( + "ENABLE_USER_WEBHOOKS", + "ui.enable_user_webhooks", + os.environ.get("ENABLE_USER_WEBHOOKS", "True").lower() == "true", +) + def validate_cors_origins(origins): for origin in origins: diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 63d5149c7..bb78d9003 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -253,6 +253,7 @@ from open_webui.config import ( ENABLE_CHANNELS, ENABLE_COMMUNITY_SHARING, ENABLE_MESSAGE_RATING, + ENABLE_USER_WEBHOOKS, ENABLE_EVALUATION_ARENA_MODELS, USER_PERMISSIONS, DEFAULT_USER_ROLE, @@ -519,6 +520,7 @@ app.state.config.MODEL_ORDER_LIST = MODEL_ORDER_LIST app.state.config.ENABLE_CHANNELS = ENABLE_CHANNELS 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 app.state.config.ENABLE_EVALUATION_ARENA_MODELS = ENABLE_EVALUATION_ARENA_MODELS app.state.config.EVALUATION_ARENA_MODELS = EVALUATION_ARENA_MODELS @@ -1231,6 +1233,7 @@ async def get_app_config(request: Request): "enable_autocomplete_generation": app.state.config.ENABLE_AUTOCOMPLETE_GENERATION, "enable_community_sharing": app.state.config.ENABLE_COMMUNITY_SHARING, "enable_message_rating": app.state.config.ENABLE_MESSAGE_RATING, + "enable_user_webhooks": app.state.config.ENABLE_USER_WEBHOOKS, "enable_admin_export": ENABLE_ADMIN_EXPORT, "enable_admin_chat_access": ENABLE_ADMIN_CHAT_ACCESS, "enable_google_drive_integration": app.state.config.ENABLE_GOOGLE_DRIVE_INTEGRATION, diff --git a/backend/open_webui/routers/auths.py b/backend/open_webui/routers/auths.py index f30ae50c3..34a63ba3f 100644 --- a/backend/open_webui/routers/auths.py +++ b/backend/open_webui/routers/auths.py @@ -639,11 +639,12 @@ async def get_admin_config(request: Request, user=Depends(get_admin_user)): "ENABLE_API_KEY": request.app.state.config.ENABLE_API_KEY, "ENABLE_API_KEY_ENDPOINT_RESTRICTIONS": request.app.state.config.ENABLE_API_KEY_ENDPOINT_RESTRICTIONS, "API_KEY_ALLOWED_ENDPOINTS": request.app.state.config.API_KEY_ALLOWED_ENDPOINTS, - "ENABLE_CHANNELS": request.app.state.config.ENABLE_CHANNELS, "DEFAULT_USER_ROLE": request.app.state.config.DEFAULT_USER_ROLE, "JWT_EXPIRES_IN": request.app.state.config.JWT_EXPIRES_IN, "ENABLE_COMMUNITY_SHARING": request.app.state.config.ENABLE_COMMUNITY_SHARING, "ENABLE_MESSAGE_RATING": request.app.state.config.ENABLE_MESSAGE_RATING, + "ENABLE_CHANNELS": request.app.state.config.ENABLE_CHANNELS, + "ENABLE_USER_WEBHOOKS": request.app.state.config.ENABLE_USER_WEBHOOKS, } @@ -654,11 +655,12 @@ class AdminConfig(BaseModel): ENABLE_API_KEY: bool ENABLE_API_KEY_ENDPOINT_RESTRICTIONS: bool API_KEY_ALLOWED_ENDPOINTS: str - ENABLE_CHANNELS: bool DEFAULT_USER_ROLE: str JWT_EXPIRES_IN: str ENABLE_COMMUNITY_SHARING: bool ENABLE_MESSAGE_RATING: bool + ENABLE_CHANNELS: bool + ENABLE_USER_WEBHOOKS: bool @router.post("/admin/config") @@ -693,6 +695,8 @@ async def update_admin_config( ) request.app.state.config.ENABLE_MESSAGE_RATING = form_data.ENABLE_MESSAGE_RATING + request.app.state.config.ENABLE_USER_WEBHOOKS = form_data.ENABLE_USER_WEBHOOKS + return { "SHOW_ADMIN_DETAILS": request.app.state.config.SHOW_ADMIN_DETAILS, "WEBUI_URL": request.app.state.config.WEBUI_URL, @@ -705,6 +709,7 @@ async def update_admin_config( "JWT_EXPIRES_IN": request.app.state.config.JWT_EXPIRES_IN, "ENABLE_COMMUNITY_SHARING": request.app.state.config.ENABLE_COMMUNITY_SHARING, "ENABLE_MESSAGE_RATING": request.app.state.config.ENABLE_MESSAGE_RATING, + "ENABLE_USER_WEBHOOKS": request.app.state.config.ENABLE_USER_WEBHOOKS, } diff --git a/src/lib/components/admin/Settings/General.svelte b/src/lib/components/admin/Settings/General.svelte index 78a15a648..5c50bf311 100644 --- a/src/lib/components/admin/Settings/General.svelte +++ b/src/lib/components/admin/Settings/General.svelte @@ -609,6 +609,14 @@ +
+
+ {$i18n.t('User Webhooks')} +
+ + +
+
{$i18n.t('WebUI URL')}
diff --git a/src/lib/components/chat/Settings/Account.svelte b/src/lib/components/chat/Settings/Account.svelte index 6b3eba153..997ec49c9 100644 --- a/src/lib/components/chat/Settings/Account.svelte +++ b/src/lib/components/chat/Settings/Account.svelte @@ -245,21 +245,23 @@
-
-
-
{$i18n.t('Notification Webhook')}
+ {#if $config?.features?.enable_user_webhooks} +
+
+
{$i18n.t('Notification Webhook')}
-
- +
+ +
-
+ {/if}