Skip to content

Commit 9b38e86

Browse files
committed
Added permission to enable/disable image capture and attch knownledge
1 parent 598282c commit 9b38e86

File tree

6 files changed

+38
-0
lines changed

6 files changed

+38
-0
lines changed

backend/open_webui/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,14 @@ def feishu_oauth_register(client: OAuth):
12511251
os.environ.get("USER_PERMISSIONS_CHAT_SYSTEM_PROMPT", "True").lower() == "true"
12521252
)
12531253

1254+
USER_PERMISSIONS_CHAT_IMAGE_CAPTURE = (
1255+
os.environ.get("USER_PERMISSIONS_CHAT_IMAGE_CAPTURE", "True").lower() == "true"
1256+
)
1257+
1258+
USER_PERMISSIONS_CHAT_ATTACH_KONWLEDGE = (
1259+
os.environ.get("USER_PERMISSIONS_CHAT_ATTACH_KONWLEDGE", "True").lower() == "true"
1260+
)
1261+
12541262
USER_PERMISSIONS_CHAT_PARAMS = (
12551263
os.environ.get("USER_PERMISSIONS_CHAT_PARAMS", "True").lower() == "true"
12561264
)
@@ -1359,6 +1367,8 @@ def feishu_oauth_register(client: OAuth):
13591367
"controls": USER_PERMISSIONS_CHAT_CONTROLS,
13601368
"valves": USER_PERMISSIONS_CHAT_VALVES,
13611369
"system_prompt": USER_PERMISSIONS_CHAT_SYSTEM_PROMPT,
1370+
"image_capture": USER_PERMISSIONS_CHAT_IMAGE_CAPTURE,
1371+
"attach_knowledge": USER_PERMISSIONS_CHAT_ATTACH_KONWLEDGE,
13621372
"params": USER_PERMISSIONS_CHAT_PARAMS,
13631373
"file_upload": USER_PERMISSIONS_CHAT_FILE_UPLOAD,
13641374
"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
@@ -163,6 +163,8 @@ class ChatPermissions(BaseModel):
163163
controls: bool = True
164164
valves: bool = True
165165
system_prompt: bool = True
166+
image_capture: bool = True
167+
attach_knowledge: bool = True
166168
params: bool = True
167169
file_upload: bool = True
168170
delete: bool = True

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
controls: true,
6969
valves: true,
7070
system_prompt: true,
71+
image_capture: true,
72+
attach_knowledge: true,
7173
params: true,
7274
file_upload: true,
7375
delete: true,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
controls: true,
5151
valves: true,
5252
system_prompt: true,
53+
image_capture: true,
54+
attach_knowledge: true,
5355
params: true,
5456
file_upload: true,
5557
delete: true,

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
valves: true,
2525
system_prompt: true,
2626
params: true,
27+
image_capture: true,
28+
attach_knowledge: true,
2729
file_upload: true,
2830
delete: true,
2931
delete_message: true,
@@ -304,6 +306,22 @@
304306
<Switch bind:state={permissions.chat.edit} />
305307
</div>
306308

309+
<div class=" flex w-full justify-between my-2 pr-2">
310+
<div class=" self-center text-xs font-medium">
311+
{$i18n.t('Allow Image capture')}
312+
</div>
313+
314+
<Switch bind:state={permissions.chat.image_capture} />
315+
</div>
316+
317+
<div class=" flex w-full justify-between my-2 pr-2">
318+
<div class=" self-center text-xs font-medium">
319+
{$i18n.t('Allow Attach Knowledge')}
320+
</div>
321+
322+
<Switch bind:state={permissions.chat.attach_knowledge} />
323+
</div>
324+
307325
<div class=" flex w-full justify-between my-2 pr-2">
308326
<div class=" self-center text-xs font-medium">
309327
{$i18n.t('Allow Chat Delete')}

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)