Skip to content

Commit ed0195d

Browse files
committed
Added permission for model import/export
1 parent 0391ac9 commit ed0195d

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

backend/open_webui/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,10 @@ def feishu_oauth_register(oauth: OAuth):
12841284
os.environ.get("USER_PERMISSIONS_CHAT_ATTACH_KONWLEDGE", "True").lower() == "true"
12851285
)
12861286

1287+
USER_PERMISSIONS_EXPORT_IMPORT_MODEL = (
1288+
os.environ.get("USER_PERMISSIONS_EXPORT_IMPORT_MODEL", "True").lower() == "true"
1289+
)
1290+
12871291
USER_PERMISSIONS_CHAT_PARAMS = (
12881292
os.environ.get("USER_PERMISSIONS_CHAT_PARAMS", "True").lower() == "true"
12891293
)
@@ -1395,6 +1399,7 @@ def feishu_oauth_register(oauth: OAuth):
13951399
"system_prompt": USER_PERMISSIONS_CHAT_SYSTEM_PROMPT,
13961400
"image_capture": USER_PERMISSIONS_CHAT_IMAGE_CAPTURE,
13971401
"attach_knowledge": USER_PERMISSIONS_CHAT_ATTACH_KONWLEDGE,
1402+
"export_import_model": USER_PERMISSIONS_EXPORT_IMPORT_MODEL,
13981403
"params": USER_PERMISSIONS_CHAT_PARAMS,
13991404
"file_upload": USER_PERMISSIONS_CHAT_FILE_UPLOAD,
14001405
"delete": USER_PERMISSIONS_CHAT_DELETE,

backend/open_webui/routers/users.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class ChatPermissions(BaseModel):
166166
system_prompt: bool = True
167167
image_capture: bool = True
168168
attach_knowledge: bool = True
169+
export_import_model: bool = True
169170
params: bool = True
170171
file_upload: bool = True
171172
delete: bool = True

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
system_prompt: true,
5454
image_capture: true,
5555
attach_knowledge: true,
56+
export_import_model: true,
5657
params: true,
5758
file_upload: true,
5859
delete: true,

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
params: true,
2828
image_capture: true,
2929
attach_knowledge: true,
30+
export_import_model: true,
3031
file_upload: true,
3132
delete: true,
3233
delete_message: true,
@@ -377,6 +378,22 @@
377378
{/if}
378379
</div>
379380

381+
<div class="flex flex-col w-full">
382+
<div class="flex w-full justify-between my-1">
383+
<div class=" self-center text-xs font-medium">
384+
{$i18n.t('Allow Import/Export models')}
385+
</div>
386+
<Switch bind:state={permissions.chat.export_import_model} />
387+
</div>
388+
{#if defaultPermissions?.chat?.export_import_model && !permissions.chat.export_import_model}
389+
<div>
390+
<div class="text-xs text-gray-500">
391+
{$i18n.t('This is a default user permission and will remain enabled.')}
392+
</div>
393+
</div>
394+
{/if}
395+
</div>
396+
380397
<div class="flex flex-col w-full">
381398
<div class="flex w-full justify-between my-1">
382399
<div class=" self-center text-xs font-medium">

src/lib/components/workspace/Models.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@
308308
</div>
309309

310310
<div class="flex w-full justify-end gap-1.5">
311-
{#if $user?.role === 'admin'}
311+
{#if $user?.role === 'admin' || $user?.permissions.chat?.export_import_model}
312312
<button
313313
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition"
314314
on:click={() => {

0 commit comments

Comments
 (0)