mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
refac/enh: chat controls permissions
This commit is contained in:
parent
84289b9a8d
commit
708e0ed05e
7 changed files with 127 additions and 78 deletions
|
|
@ -1143,10 +1143,18 @@ USER_PERMISSIONS_CHAT_CONTROLS = (
|
||||||
os.environ.get("USER_PERMISSIONS_CHAT_CONTROLS", "True").lower() == "true"
|
os.environ.get("USER_PERMISSIONS_CHAT_CONTROLS", "True").lower() == "true"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
USER_PERMISSIONS_CHAT_VALVES = (
|
||||||
|
os.environ.get("USER_PERMISSIONS_CHAT_VALVES", "True").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
USER_PERMISSIONS_CHAT_SYSTEM_PROMPT = (
|
USER_PERMISSIONS_CHAT_SYSTEM_PROMPT = (
|
||||||
os.environ.get("USER_PERMISSIONS_CHAT_SYSTEM_PROMPT", "True").lower() == "true"
|
os.environ.get("USER_PERMISSIONS_CHAT_SYSTEM_PROMPT", "True").lower() == "true"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
USER_PERMISSIONS_CHAT_PARAMS = (
|
||||||
|
os.environ.get("USER_PERMISSIONS_CHAT_PARAMS", "True").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
USER_PERMISSIONS_CHAT_FILE_UPLOAD = (
|
USER_PERMISSIONS_CHAT_FILE_UPLOAD = (
|
||||||
os.environ.get("USER_PERMISSIONS_CHAT_FILE_UPLOAD", "True").lower() == "true"
|
os.environ.get("USER_PERMISSIONS_CHAT_FILE_UPLOAD", "True").lower() == "true"
|
||||||
)
|
)
|
||||||
|
|
@ -1232,7 +1240,9 @@ DEFAULT_USER_PERMISSIONS = {
|
||||||
},
|
},
|
||||||
"chat": {
|
"chat": {
|
||||||
"controls": USER_PERMISSIONS_CHAT_CONTROLS,
|
"controls": USER_PERMISSIONS_CHAT_CONTROLS,
|
||||||
|
"valves": USER_PERMISSIONS_CHAT_VALVES,
|
||||||
"system_prompt": USER_PERMISSIONS_CHAT_SYSTEM_PROMPT,
|
"system_prompt": USER_PERMISSIONS_CHAT_SYSTEM_PROMPT,
|
||||||
|
"params": USER_PERMISSIONS_CHAT_PARAMS,
|
||||||
"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,
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,9 @@ class SharingPermissions(BaseModel):
|
||||||
|
|
||||||
class ChatPermissions(BaseModel):
|
class ChatPermissions(BaseModel):
|
||||||
controls: bool = True
|
controls: bool = True
|
||||||
|
valves: bool = True
|
||||||
system_prompt: bool = True
|
system_prompt: bool = True
|
||||||
|
params: bool = True
|
||||||
file_upload: bool = True
|
file_upload: bool = True
|
||||||
delete: bool = True
|
delete: bool = True
|
||||||
edit: bool = True
|
edit: bool = True
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,9 @@
|
||||||
},
|
},
|
||||||
chat: {
|
chat: {
|
||||||
controls: true,
|
controls: true,
|
||||||
|
valves: true,
|
||||||
system_prompt: true,
|
system_prompt: true,
|
||||||
|
params: true,
|
||||||
file_upload: true,
|
file_upload: true,
|
||||||
delete: true,
|
delete: true,
|
||||||
edit: true,
|
edit: true,
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,20 @@
|
||||||
},
|
},
|
||||||
chat: {
|
chat: {
|
||||||
controls: true,
|
controls: true,
|
||||||
|
valves: true,
|
||||||
|
system_prompt: true,
|
||||||
|
params: true,
|
||||||
file_upload: true,
|
file_upload: true,
|
||||||
delete: true,
|
delete: true,
|
||||||
edit: true,
|
edit: true,
|
||||||
temporary: true
|
share: true,
|
||||||
|
export: true,
|
||||||
|
stt: true,
|
||||||
|
tts: true,
|
||||||
|
call: true,
|
||||||
|
multiple_models: true,
|
||||||
|
temporary: true,
|
||||||
|
temporary_enforced: false
|
||||||
},
|
},
|
||||||
features: {
|
features: {
|
||||||
direct_tool_servers: false,
|
direct_tool_servers: false,
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@
|
||||||
},
|
},
|
||||||
chat: {
|
chat: {
|
||||||
controls: true,
|
controls: true,
|
||||||
|
valves: true,
|
||||||
|
system_prompt: true,
|
||||||
|
params: true,
|
||||||
file_upload: true,
|
file_upload: true,
|
||||||
delete: true,
|
delete: true,
|
||||||
edit: true,
|
edit: true,
|
||||||
|
|
@ -263,6 +266,14 @@
|
||||||
<Switch bind:state={permissions.chat.controls} />
|
<Switch bind:state={permissions.chat.controls} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class=" flex w-full justify-between my-2 pr-2">
|
||||||
|
<div class=" self-center text-xs font-medium">
|
||||||
|
{$i18n.t('Allow Chat Valves')}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Switch bind:state={permissions.chat.valves} />
|
||||||
|
</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 Chat System Prompt')}
|
{$i18n.t('Allow Chat System Prompt')}
|
||||||
|
|
@ -271,6 +282,14 @@
|
||||||
<Switch bind:state={permissions.chat.system_prompt} />
|
<Switch bind:state={permissions.chat.system_prompt} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class=" flex w-full justify-between my-2 pr-2">
|
||||||
|
<div class=" self-center text-xs font-medium">
|
||||||
|
{$i18n.t('Allow Chat Params')}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Switch bind:state={permissions.chat.params} />
|
||||||
|
</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 Chat Delete')}
|
{$i18n.t('Allow Chat Delete')}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{#if $user?.role === 'admin' || ($user?.permissions.chat?.controls ?? true)}
|
||||||
<div class=" dark:text-gray-200 text-sm font-primary py-0.5 px-0.5">
|
<div class=" dark:text-gray-200 text-sm font-primary py-0.5 px-0.5">
|
||||||
{#if chatFiles.length > 0}
|
{#if chatFiles.length > 0}
|
||||||
<Collapsible title={$i18n.t('Files')} open={true} buttonClassName="w-full">
|
<Collapsible title={$i18n.t('Files')} open={true} buttonClassName="w-full">
|
||||||
|
|
@ -61,11 +62,13 @@
|
||||||
<hr class="my-2 border-gray-50 dark:border-gray-700/10" />
|
<hr class="my-2 border-gray-50 dark:border-gray-700/10" />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if $user?.role === 'admin' || ($user?.permissions.chat?.valves ?? true)}
|
||||||
<Collapsible bind:open={showValves} title={$i18n.t('Valves')} buttonClassName="w-full">
|
<Collapsible bind:open={showValves} title={$i18n.t('Valves')} buttonClassName="w-full">
|
||||||
<div class="text-sm" slot="content">
|
<div class="text-sm" slot="content">
|
||||||
<Valves show={showValves} />
|
<Valves show={showValves} />
|
||||||
</div>
|
</div>
|
||||||
</Collapsible>
|
</Collapsible>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if $user?.role === 'admin' || ($user?.permissions.chat?.system_prompt ?? true)}
|
{#if $user?.role === 'admin' || ($user?.permissions.chat?.system_prompt ?? true)}
|
||||||
<hr class="my-2 border-gray-50 dark:border-gray-700/10" />
|
<hr class="my-2 border-gray-50 dark:border-gray-700/10" />
|
||||||
|
|
@ -84,7 +87,7 @@
|
||||||
</Collapsible>
|
</Collapsible>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if $user?.role === 'admin' || ($user?.permissions.chat?.controls ?? true)}
|
{#if $user?.role === 'admin' || ($user?.permissions.chat?.params ?? true)}
|
||||||
<hr class="my-2 border-gray-50 dark:border-gray-700/10" />
|
<hr class="my-2 border-gray-50 dark:border-gray-700/10" />
|
||||||
|
|
||||||
<Collapsible title={$i18n.t('Advanced Params')} open={true} buttonClassName="w-full">
|
<Collapsible title={$i18n.t('Advanced Params')} open={true} buttonClassName="w-full">
|
||||||
|
|
@ -96,4 +99,5 @@
|
||||||
</Collapsible>
|
</Collapsible>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@
|
||||||
</Menu>
|
</Menu>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if $user?.role === 'admin' || ($user?.permissions.chat?.controls ?? true)}
|
||||||
<Tooltip content={$i18n.t('Controls')}>
|
<Tooltip content={$i18n.t('Controls')}>
|
||||||
<button
|
<button
|
||||||
class=" flex cursor-pointer px-2 py-2 rounded-xl hover:bg-gray-50 dark:hover:bg-gray-850 transition"
|
class=" flex cursor-pointer px-2 py-2 rounded-xl hover:bg-gray-50 dark:hover:bg-gray-850 transition"
|
||||||
|
|
@ -164,6 +165,7 @@
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if $mobile}
|
{#if $mobile}
|
||||||
<Tooltip content={$i18n.t('New Chat')}>
|
<Tooltip content={$i18n.t('New Chat')}>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue