From d932fc555decf53d532e977259ede72ddf2ceb12 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 14 Apr 2025 01:40:22 -0700 Subject: [PATCH] enh: tts/stt user permissions --- backend/open_webui/config.py | 15 +++++++ backend/open_webui/routers/users.py | 3 ++ src/lib/components/admin/Users/Groups.svelte | 3 ++ .../admin/Users/Groups/Permissions.svelte | 44 +++++++++++++++---- src/lib/components/chat/MessageInput.svelte | 4 +- 5 files changed, 58 insertions(+), 11 deletions(-) diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index 45a5dfbdb..3b40977f2 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -1062,6 +1062,18 @@ USER_PERMISSIONS_CHAT_EDIT = ( os.environ.get("USER_PERMISSIONS_CHAT_EDIT", "True").lower() == "true" ) +USER_PERMISSIONS_CHAT_STT = ( + os.environ.get("USER_PERMISSIONS_CHAT_STT", "True").lower() == "true" +) + +USER_PERMISSIONS_CHAT_TTS = ( + os.environ.get("USER_PERMISSIONS_CHAT_TTS", "True").lower() == "true" +) + +USER_PERMISSIONS_CHAT_CALL = ( + os.environ.get("USER_PERMISSIONS_CHAT_CALL", "True").lower() == "true" +) + USER_PERMISSIONS_CHAT_MULTIPLE_MODELS = ( os.environ.get("USER_PERMISSIONS_CHAT_MULTIPLE_MODELS", "True").lower() == "true" ) @@ -1114,6 +1126,9 @@ DEFAULT_USER_PERMISSIONS = { "file_upload": USER_PERMISSIONS_CHAT_FILE_UPLOAD, "delete": USER_PERMISSIONS_CHAT_DELETE, "edit": USER_PERMISSIONS_CHAT_EDIT, + "stt": USER_PERMISSIONS_CHAT_STT, + "tts": USER_PERMISSIONS_CHAT_TTS, + "call": USER_PERMISSIONS_CHAT_CALL, "multiple_models": USER_PERMISSIONS_CHAT_MULTIPLE_MODELS, "temporary": USER_PERMISSIONS_CHAT_TEMPORARY, "temporary_enforced": USER_PERMISSIONS_CHAT_TEMPORARY_ENFORCED, diff --git a/backend/open_webui/routers/users.py b/backend/open_webui/routers/users.py index 781676567..a9ac34e2f 100644 --- a/backend/open_webui/routers/users.py +++ b/backend/open_webui/routers/users.py @@ -88,6 +88,9 @@ class ChatPermissions(BaseModel): file_upload: bool = True delete: bool = True edit: bool = True + stt: bool = True + tts: bool = True + call: bool = True multiple_models: bool = True temporary: bool = True temporary_enforced: bool = False diff --git a/src/lib/components/admin/Users/Groups.svelte b/src/lib/components/admin/Users/Groups.svelte index 5c37badfd..dce8423e5 100644 --- a/src/lib/components/admin/Users/Groups.svelte +++ b/src/lib/components/admin/Users/Groups.svelte @@ -63,6 +63,9 @@ file_upload: true, delete: true, edit: true, + stt: true, + tts: true, + call: true, multiple_models: true, temporary: true, temporary_enforced: false diff --git a/src/lib/components/admin/Users/Groups/Permissions.svelte b/src/lib/components/admin/Users/Groups/Permissions.svelte index 3b722c432..c7a1308a5 100644 --- a/src/lib/components/admin/Users/Groups/Permissions.svelte +++ b/src/lib/components/admin/Users/Groups/Permissions.svelte @@ -21,9 +21,12 @@ }, chat: { controls: true, + file_upload: true, delete: true, edit: true, - file_upload: true, + stt: true, + tts: true, + call: true, multiple_models: true, temporary: true, temporary_enforced: false @@ -241,14 +244,6 @@
{$i18n.t('Chat Permissions')}
-
-
- {$i18n.t('Allow Chat Controls')} -
- - -
-
{$i18n.t('Allow File Upload')} @@ -257,6 +252,14 @@
+
+
+ {$i18n.t('Allow Chat Controls')} +
+ + +
+
{$i18n.t('Allow Chat Delete')} @@ -273,6 +276,29 @@
+
+
+ {$i18n.t('Allow Speech to Text')} +
+ + +
+
+
+ {$i18n.t('Allow Text to Speech')} +
+ + +
+ +
+
+ {$i18n.t('Allow Call')} +
+ + +
+
{$i18n.t('Allow Multiple Models in Chat')} diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index 47ed89a32..ca6487cf5 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -1189,7 +1189,7 @@
- {#if !history?.currentId || history.messages[history.currentId]?.done == true} + {#if (!history?.currentId || history.messages[history.currentId]?.done == true) && ($_user?.role === 'admin' || ($_user?.permissions?.chat?.stt ?? true))}
- {:else if prompt === '' && files.length === 0} + {:else if prompt === '' && files.length === 0 && ($_user?.role === 'admin' || ($_user?.permissions?.chat?.call ?? true))}