feat: multiple models chat user permissions

This commit is contained in:
Timothy Jaeryang Baek 2025-04-12 17:37:30 -07:00
parent 881d81d87f
commit 79dff685ea
5 changed files with 69 additions and 50 deletions

View File

@ -1062,6 +1062,10 @@ USER_PERMISSIONS_CHAT_EDIT = (
os.environ.get("USER_PERMISSIONS_CHAT_EDIT", "True").lower() == "true" os.environ.get("USER_PERMISSIONS_CHAT_EDIT", "True").lower() == "true"
) )
USER_PERMISSIONS_CHAT_MULTIPLE_MODELS = (
os.environ.get("USER_PERMISSIONS_CHAT_MULTIPLE_MODELS", "True").lower() == "true"
)
USER_PERMISSIONS_CHAT_TEMPORARY = ( USER_PERMISSIONS_CHAT_TEMPORARY = (
os.environ.get("USER_PERMISSIONS_CHAT_TEMPORARY", "True").lower() == "true" os.environ.get("USER_PERMISSIONS_CHAT_TEMPORARY", "True").lower() == "true"
) )
@ -1071,6 +1075,7 @@ USER_PERMISSIONS_CHAT_TEMPORARY_ENFORCED = (
== "true" == "true"
) )
USER_PERMISSIONS_FEATURES_DIRECT_TOOL_SERVERS = ( USER_PERMISSIONS_FEATURES_DIRECT_TOOL_SERVERS = (
os.environ.get("USER_PERMISSIONS_FEATURES_DIRECT_TOOL_SERVERS", "False").lower() os.environ.get("USER_PERMISSIONS_FEATURES_DIRECT_TOOL_SERVERS", "False").lower()
== "true" == "true"
@ -1109,6 +1114,7 @@ DEFAULT_USER_PERMISSIONS = {
"file_upload": USER_PERMISSIONS_CHAT_FILE_UPLOAD, "file_upload": USER_PERMISSIONS_CHAT_FILE_UPLOAD,
"delete": USER_PERMISSIONS_CHAT_DELETE, "delete": USER_PERMISSIONS_CHAT_DELETE,
"edit": USER_PERMISSIONS_CHAT_EDIT, "edit": USER_PERMISSIONS_CHAT_EDIT,
"multiple_models": USER_PERMISSIONS_CHAT_MULTIPLE_MODELS,
"temporary": USER_PERMISSIONS_CHAT_TEMPORARY, "temporary": USER_PERMISSIONS_CHAT_TEMPORARY,
"temporary_enforced": USER_PERMISSIONS_CHAT_TEMPORARY_ENFORCED, "temporary_enforced": USER_PERMISSIONS_CHAT_TEMPORARY_ENFORCED,
}, },

View File

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

View File

@ -63,6 +63,7 @@
file_upload: true, file_upload: true,
delete: true, delete: true,
edit: true, edit: true,
multiple_models: true,
temporary: true, temporary: true,
temporary_enforced: false temporary_enforced: false
}, },

View File

@ -24,6 +24,7 @@
delete: true, delete: true,
edit: true, edit: true,
file_upload: true, file_upload: true,
multiple_models: true,
temporary: true, temporary: true,
temporary_enforced: false temporary_enforced: false
}, },
@ -272,6 +273,14 @@
<Switch bind:state={permissions.chat.edit} /> <Switch bind:state={permissions.chat.edit} />
</div> </div>
<div class=" flex w-full justify-between my-2 pr-2">
<div class=" self-center text-xs font-medium">
{$i18n.t('Allow Multiple Models in Chat')}
</div>
<Switch bind:state={permissions.chat.multiple_models} />
</div>
<div class=" flex w-full justify-between my-2 pr-2"> <div class=" flex w-full justify-between my-2 pr-2">
<div class=" self-center text-xs font-medium"> <div class=" self-center text-xs font-medium">
{$i18n.t('Allow Temporary Chat')} {$i18n.t('Allow Temporary Chat')}

View File

@ -54,6 +54,7 @@
</div> </div>
</div> </div>
{#if $user?.role === 'admin' || ($user?.permissions?.chat?.multiple_models ?? true)}
{#if selectedModelIdx === 0} {#if selectedModelIdx === 0}
<div <div
class=" self-center mx-1 disabled:text-gray-600 disabled:hover:text-gray-600 -translate-y-[0.5px]" class=" self-center mx-1 disabled:text-gray-600 disabled:hover:text-gray-600 -translate-y-[0.5px]"
@ -107,6 +108,7 @@
</Tooltip> </Tooltip>
</div> </div>
{/if} {/if}
{/if}
</div> </div>
{/each} {/each}
</div> </div>