Skip to content

Commit c831de5

Browse files
committed
Added permission to enable/disable image capture and attch knownledge
1 parent 8d7d79d commit c831de5

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
@@ -1261,6 +1261,14 @@ def feishu_oauth_register(oauth: OAuth):
12611261
os.environ.get("USER_PERMISSIONS_CHAT_SYSTEM_PROMPT", "True").lower() == "true"
12621262
)
12631263

1264+
USER_PERMISSIONS_CHAT_IMAGE_CAPTURE = (
1265+
os.environ.get("USER_PERMISSIONS_CHAT_IMAGE_CAPTURE", "True").lower() == "true"
1266+
)
1267+
1268+
USER_PERMISSIONS_CHAT_ATTACH_KONWLEDGE = (
1269+
os.environ.get("USER_PERMISSIONS_CHAT_ATTACH_KONWLEDGE", "True").lower() == "true"
1270+
)
1271+
12641272
USER_PERMISSIONS_CHAT_PARAMS = (
12651273
os.environ.get("USER_PERMISSIONS_CHAT_PARAMS", "True").lower() == "true"
12661274
)
@@ -1370,6 +1378,8 @@ def feishu_oauth_register(oauth: OAuth):
13701378
"controls": USER_PERMISSIONS_CHAT_CONTROLS,
13711379
"valves": USER_PERMISSIONS_CHAT_VALVES,
13721380
"system_prompt": USER_PERMISSIONS_CHAT_SYSTEM_PROMPT,
1381+
"image_capture": USER_PERMISSIONS_CHAT_IMAGE_CAPTURE,
1382+
"attach_knowledge": USER_PERMISSIONS_CHAT_ATTACH_KONWLEDGE,
13731383
"params": USER_PERMISSIONS_CHAT_PARAMS,
13741384
"file_upload": USER_PERMISSIONS_CHAT_FILE_UPLOAD,
13751385
"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
@@ -164,6 +164,8 @@ class ChatPermissions(BaseModel):
164164
controls: bool = True
165165
valves: bool = True
166166
system_prompt: bool = True
167+
image_capture: bool = True
168+
attach_knowledge: bool = True
167169
params: bool = True
168170
file_upload: bool = True
169171
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
@@ -51,6 +51,8 @@
5151
controls: true,
5252
valves: true,
5353
system_prompt: true,
54+
image_capture: true,
55+
attach_knowledge: true,
5456
params: true,
5557
file_upload: true,
5658
delete: true,

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
valves: true,
2626
system_prompt: true,
2727
params: true,
28+
image_capture: true,
29+
attach_knowledge: true,
2830
file_upload: true,
2931
delete: true,
3032
delete_message: true,
@@ -343,6 +345,38 @@
343345
{/if}
344346
</div>
345347

348+
<div class="flex flex-col w-full">
349+
<div class="flex w-full justify-between my-1">
350+
<div class=" self-center text-xs font-medium">
351+
{$i18n.t('Allow Image capture')}
352+
</div>
353+
<Switch bind:state={permissions.chat.image_capture} />
354+
</div>
355+
{#if defaultPermissions?.chat?.image_capture && !permissions.chat.image_capture}
356+
<div>
357+
<div class="text-xs text-gray-500">
358+
{$i18n.t('This is a default user permission and will remain enabled.')}
359+
</div>
360+
</div>
361+
{/if}
362+
</div>
363+
364+
<div class="flex flex-col w-full">
365+
<div class="flex w-full justify-between my-1">
366+
<div class=" self-center text-xs font-medium">
367+
{$i18n.t('Allow Attach Knowledge')}
368+
</div>
369+
<Switch bind:state={permissions.chat.attach_knowledge} />
370+
</div>
371+
{#if defaultPermissions?.chat?.attach_knowledge && !permissions.chat.attach_knowledge}
372+
<div>
373+
<div class="text-xs text-gray-500">
374+
{$i18n.t('This is a default user permission and will remain enabled.')}
375+
</div>
376+
</div>
377+
{/if}
378+
</div>
379+
346380
<div class="flex flex-col w-full">
347381
<div class="flex w-full justify-between my-1">
348382
<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
@@ -159,6 +159,7 @@
159159
</DropdownMenu.Item>
160160
</Tooltip>
161161

162+
{#if $user?.role === 'admin' || $user?.permissions.chat?.image_capture}
162163
<Tooltip
163164
content={fileUploadCapableModels.length !== selectedModels.length
164165
? $i18n.t('Model(s) do not support file upload')
@@ -189,6 +190,7 @@
189190
<div class=" line-clamp-1">{$i18n.t('Capture')}</div>
190191
</DropdownMenu.Item>
191192
</Tooltip>
193+
{/if}
192194

193195
<Tooltip
194196
content={fileUploadCapableModels.length !== selectedModels.length
@@ -244,6 +246,7 @@
244246
{/if}
245247

246248
{#if ($knowledge ?? []).length > 0}
249+
{#if $user?.role === 'admin' || $user?.permissions.chat?.attach_knowledge}
247250
<Tooltip
248251
content={fileUploadCapableModels.length !== selectedModels.length
249252
? $i18n.t('Model(s) do not support file upload')
@@ -273,6 +276,7 @@
273276
</div>
274277
</button>
275278
</Tooltip>
279+
{/if}
276280
{/if}
277281

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

0 commit comments

Comments
 (0)