Explorar o código

enh: tts/stt user permissions

Timothy Jaeryang Baek hai 3 semanas
pai
achega
d932fc555d

+ 15 - 0
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,

+ 3 - 0
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

+ 3 - 0
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

+ 31 - 5
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
@@ -243,18 +246,18 @@
 
 		<div class="  flex w-full justify-between my-2 pr-2">
 			<div class=" self-center text-xs font-medium">
-				{$i18n.t('Allow Chat Controls')}
+				{$i18n.t('Allow File Upload')}
 			</div>
 
-			<Switch bind:state={permissions.chat.controls} />
+			<Switch bind:state={permissions.chat.file_upload} />
 		</div>
 
 		<div class="  flex w-full justify-between my-2 pr-2">
 			<div class=" self-center text-xs font-medium">
-				{$i18n.t('Allow File Upload')}
+				{$i18n.t('Allow Chat Controls')}
 			</div>
 
-			<Switch bind:state={permissions.chat.file_upload} />
+			<Switch bind:state={permissions.chat.controls} />
 		</div>
 
 		<div class="  flex w-full justify-between my-2 pr-2">
@@ -273,6 +276,29 @@
 			<Switch bind:state={permissions.chat.edit} />
 		</div>
 
+		<div class="  flex w-full justify-between my-2 pr-2">
+			<div class=" self-center text-xs font-medium">
+				{$i18n.t('Allow Speech to Text')}
+			</div>
+
+			<Switch bind:state={permissions.chat.stt} />
+		</div>
+		<div class="  flex w-full justify-between my-2 pr-2">
+			<div class=" self-center text-xs font-medium">
+				{$i18n.t('Allow Text to Speech')}
+			</div>
+
+			<Switch bind:state={permissions.chat.tts} />
+		</div>
+
+		<div class="  flex w-full justify-between my-2 pr-2">
+			<div class=" self-center text-xs font-medium">
+				{$i18n.t('Allow Call')}
+			</div>
+
+			<Switch bind:state={permissions.chat.call} />
+		</div>
+
 		<div class="  flex w-full justify-between my-2 pr-2">
 			<div class=" self-center text-xs font-medium">
 				{$i18n.t('Allow Multiple Models in Chat')}

+ 2 - 2
src/lib/components/chat/MessageInput.svelte

@@ -1189,7 +1189,7 @@
 									</div>
 
 									<div class="self-end flex space-x-1 mr-1 shrink-0">
-										{#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))}
 											<Tooltip content={$i18n.t('Record voice')}>
 												<button
 													id="voice-input-button"
@@ -1262,7 +1262,7 @@
 													</button>
 												</Tooltip>
 											</div>
-										{:else if prompt === '' && files.length === 0}
+										{:else if prompt === '' && files.length === 0 && ($_user?.role === 'admin' || ($_user?.permissions?.chat?.call ?? true))}
 											<div class=" flex items-center">
 												<Tooltip content={$i18n.t('Call')}>
 													<button