Преглед на файлове

feat: enforced temporary chat

Timothy Jaeryang Baek преди 1 месец
родител
ревизия
5f792d2771

+ 5 - 0
backend/open_webui/config.py

@@ -1029,6 +1029,10 @@ USER_PERMISSIONS_CHAT_TEMPORARY = (
     os.environ.get("USER_PERMISSIONS_CHAT_TEMPORARY", "True").lower() == "true"
 )
 
+USER_PERMISSIONS_CHAT_TEMPORARY_ENFORCED = (
+    os.environ.get("USER_PERMISSIONS_CHAT_TEMPORARY_ENFORCED", "False").lower()
+    == "true"
+)
 
 USER_PERMISSIONS_FEATURES_WEB_SEARCH = (
     os.environ.get("USER_PERMISSIONS_FEATURES_WEB_SEARCH", "True").lower() == "true"
@@ -1064,6 +1068,7 @@ DEFAULT_USER_PERMISSIONS = {
         "delete": USER_PERMISSIONS_CHAT_DELETE,
         "edit": USER_PERMISSIONS_CHAT_EDIT,
         "temporary": USER_PERMISSIONS_CHAT_TEMPORARY,
+        "temporary_enforced": USER_PERMISSIONS_CHAT_TEMPORARY_ENFORCED,
     },
     "features": {
         "web_search": USER_PERMISSIONS_FEATURES_WEB_SEARCH,

+ 1 - 0
backend/open_webui/routers/users.py

@@ -89,6 +89,7 @@ class ChatPermissions(BaseModel):
     delete: bool = True
     edit: bool = True
     temporary: bool = True
+    temporary_enforced: bool = False
 
 
 class FeaturesPermissions(BaseModel):

+ 8 - 1
src/lib/components/admin/Users/Groups.svelte

@@ -52,12 +52,19 @@
 			prompts: false,
 			tools: false
 		},
+		sharing: {
+			public_models: false,
+			public_knowledge: false,
+			public_prompts: false,
+			public_tools: false
+		},
 		chat: {
 			controls: true,
 			file_upload: true,
 			delete: true,
 			edit: true,
-			temporary: true
+			temporary: true,
+			temporary_enforced: true
 		},
 		features: {
 			web_search: true,

+ 12 - 1
src/lib/components/admin/Users/Groups/Permissions.svelte

@@ -23,8 +23,9 @@
 			controls: true,
 			delete: true,
 			edit: true,
+			file_upload: true,
 			temporary: true,
-			file_upload: true
+			temporary_enforced: true
 		},
 		features: {
 			web_search: true,
@@ -277,6 +278,16 @@
 
 			<Switch bind:state={permissions.chat.temporary} />
 		</div>
+
+		{#if permissions.chat.temporary}
+			<div class="  flex w-full justify-between my-2 pr-2">
+				<div class=" self-center text-xs font-medium">
+					{$i18n.t('Enforce Temporary Chat')}
+				</div>
+
+				<Switch bind:state={permissions.chat.temporary_enforced} />
+			</div>
+		{/if}
 	</div>
 
 	<hr class=" border-gray-100 dark:border-gray-850 my-2" />

+ 2 - 1
src/lib/components/chat/ModelSelector.svelte

@@ -46,7 +46,8 @@
 							model: model
 						}))}
 						showTemporaryChatControl={$user.role === 'user'
-							? ($user?.permissions?.chat?.temporary ?? true)
+							? ($user?.permissions?.chat?.temporary ?? true) &&
+								!($user?.permissions?.chat?.temporary_enforced ?? false)
 							: true}
 						bind:value={selectedModel}
 					/>

+ 6 - 0
src/routes/(app)/+layout.svelte

@@ -199,6 +199,12 @@
 				temporaryChatEnabled.set(true);
 			}
 
+			console.log($user.permissions);
+
+			if ($user?.permissions?.chat?.temporary_enforced) {
+				temporaryChatEnabled.set(true);
+			}
+
 			// Check for version updates
 			if ($user.role === 'admin') {
 				// Check if the user has dismissed the update toast in the last 24 hours