Skip to content

Commit 7cfaa8b

Browse files
committed
Added permission to enable/disable image capture and attch knownledge
1 parent e3faec6 commit 7cfaa8b

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed

backend/open_webui/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,14 @@ def feishu_oauth_register(oauth: OAuth):
13571357
os.environ.get("USER_PERMISSIONS_CHAT_SYSTEM_PROMPT", "True").lower() == "true"
13581358
)
13591359

1360+
USER_PERMISSIONS_CHAT_IMAGE_CAPTURE = (
1361+
os.environ.get("USER_PERMISSIONS_CHAT_IMAGE_CAPTURE", "True").lower() == "true"
1362+
)
1363+
1364+
USER_PERMISSIONS_CHAT_ATTACH_KONWLEDGE = (
1365+
os.environ.get("USER_PERMISSIONS_CHAT_ATTACH_KONWLEDGE", "True").lower() == "true"
1366+
)
1367+
13601368
USER_PERMISSIONS_CHAT_PARAMS = (
13611369
os.environ.get("USER_PERMISSIONS_CHAT_PARAMS", "True").lower() == "true"
13621370
)
@@ -1481,6 +1489,8 @@ def feishu_oauth_register(oauth: OAuth):
14811489
"controls": USER_PERMISSIONS_CHAT_CONTROLS,
14821490
"valves": USER_PERMISSIONS_CHAT_VALVES,
14831491
"system_prompt": USER_PERMISSIONS_CHAT_SYSTEM_PROMPT,
1492+
"image_capture": USER_PERMISSIONS_CHAT_IMAGE_CAPTURE,
1493+
"attach_knowledge": USER_PERMISSIONS_CHAT_ATTACH_KONWLEDGE,
14841494
"params": USER_PERMISSIONS_CHAT_PARAMS,
14851495
"file_upload": USER_PERMISSIONS_CHAT_FILE_UPLOAD,
14861496
"delete": USER_PERMISSIONS_CHAT_DELETE,

backend/open_webui/routers/users.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ class ChatPermissions(BaseModel):
199199
controls: bool = True
200200
valves: bool = True
201201
system_prompt: bool = True
202+
image_capture: bool = True
203+
attach_knowledge: bool = True
202204
params: bool = True
203205
file_upload: bool = True
204206
delete: bool = True

src/lib/components/admin/Users/Groups/EditGroupModal.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
controls: true,
6666
valves: true,
6767
system_prompt: true,
68+
image_capture: true,
69+
attach_knowledge: true,
6870
params: true,
6971
file_upload: true,
7072
delete: true,

src/lib/components/admin/Users/Groups/Permissions.svelte

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
valves: true,
3737
system_prompt: true,
3838
params: true,
39+
image_capture: true,
40+
attach_knowledge: true,
3941
file_upload: true,
4042
delete: true,
4143
delete_message: true,
@@ -493,6 +495,38 @@
493495
{/if}
494496
</div>
495497

498+
<div class="flex flex-col w-full">
499+
<div class="flex w-full justify-between my-1">
500+
<div class=" self-center text-xs font-medium">
501+
{$i18n.t('Allow Image capture')}
502+
</div>
503+
<Switch bind:state={permissions.chat.image_capture} />
504+
</div>
505+
{#if defaultPermissions?.chat?.image_capture && !permissions.chat.image_capture}
506+
<div>
507+
<div class="text-xs text-gray-500">
508+
{$i18n.t('This is a default user permission and will remain enabled.')}
509+
</div>
510+
</div>
511+
{/if}
512+
</div>
513+
514+
<div class="flex flex-col w-full">
515+
<div class="flex w-full justify-between my-1">
516+
<div class=" self-center text-xs font-medium">
517+
{$i18n.t('Allow Attach Knowledge')}
518+
</div>
519+
<Switch bind:state={permissions.chat.attach_knowledge} />
520+
</div>
521+
{#if defaultPermissions?.chat?.attach_knowledge && !permissions.chat.attach_knowledge}
522+
<div>
523+
<div class="text-xs text-gray-500">
524+
{$i18n.t('This is a default user permission and will remain enabled.')}
525+
</div>
526+
</div>
527+
{/if}
528+
</div>
529+
496530
<div class="flex flex-col w-full">
497531
<div class="flex w-full justify-between my-1">
498532
<div class=" self-center text-xs font-medium">

src/lib/components/chat/MessageInput/InputMenu.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
</DropdownMenu.Item>
164164
</Tooltip>
165165

166+
{#if $user?.role === 'admin' || $user?.permissions.chat?.image_capture}
166167
<Tooltip
167168
content={fileUploadCapableModels.length !== selectedModels.length
168169
? $i18n.t('Model(s) do not support file upload')
@@ -193,6 +194,7 @@
193194
<div class=" line-clamp-1">{$i18n.t('Capture')}</div>
194195
</DropdownMenu.Item>
195196
</Tooltip>
197+
{/if}
196198

197199
<Tooltip
198200
content={fileUploadCapableModels.length !== selectedModels.length
@@ -250,6 +252,7 @@
250252
{/if}
251253

252254
{#if ($knowledge ?? []).length > 0}
255+
{#if $user?.role === 'admin' || $user?.permissions.chat?.attach_knowledge}
253256
<Tooltip
254257
content={fileUploadCapableModels.length !== selectedModels.length
255258
? $i18n.t('Model(s) do not support file upload')
@@ -279,6 +282,7 @@
279282
</div>
280283
</button>
281284
</Tooltip>
285+
{/if}
282286
{/if}
283287

284288
{#if ($chats ?? []).length > 0}

0 commit comments

Comments
 (0)