mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-14 21:35:19 +00:00
enh: delete_message, continue_response, regenerate_response, rate_response user permissions
Co-Authored-By: G30 <50341825+silentoplayz@users.noreply.github.com>
This commit is contained in:
parent
23a9731899
commit
803b2e35be
7 changed files with 221 additions and 146 deletions
|
|
@ -1208,6 +1208,23 @@ USER_PERMISSIONS_CHAT_DELETE = (
|
|||
os.environ.get("USER_PERMISSIONS_CHAT_DELETE", "True").lower() == "true"
|
||||
)
|
||||
|
||||
USER_PERMISSIONS_CHAT_DELETE_MESSAGE = (
|
||||
os.environ.get("USER_PERMISSIONS_CHAT_DELETE_MESSAGE", "True").lower() == "true"
|
||||
)
|
||||
|
||||
USER_PERMISSIONS_CHAT_CONTINUE_RESPONSE = (
|
||||
os.environ.get("USER_PERMISSIONS_CHAT_CONTINUE_RESPONSE", "True").lower() == "true"
|
||||
)
|
||||
|
||||
USER_PERMISSIONS_CHAT_REGENERATE_RESPONSE = (
|
||||
os.environ.get("USER_PERMISSIONS_CHAT_REGENERATE_RESPONSE", "True").lower()
|
||||
== "true"
|
||||
)
|
||||
|
||||
USER_PERMISSIONS_CHAT_RATE_RESPONSE = (
|
||||
os.environ.get("USER_PERMISSIONS_CHAT_RATE_RESPONSE", "True").lower() == "true"
|
||||
)
|
||||
|
||||
USER_PERMISSIONS_CHAT_EDIT = (
|
||||
os.environ.get("USER_PERMISSIONS_CHAT_EDIT", "True").lower() == "true"
|
||||
)
|
||||
|
|
@ -1290,6 +1307,10 @@ DEFAULT_USER_PERMISSIONS = {
|
|||
"params": USER_PERMISSIONS_CHAT_PARAMS,
|
||||
"file_upload": USER_PERMISSIONS_CHAT_FILE_UPLOAD,
|
||||
"delete": USER_PERMISSIONS_CHAT_DELETE,
|
||||
"delete_message": USER_PERMISSIONS_CHAT_DELETE_MESSAGE,
|
||||
"continue_response": USER_PERMISSIONS_CHAT_CONTINUE_RESPONSE,
|
||||
"regenerate_response": USER_PERMISSIONS_CHAT_REGENERATE_RESPONSE,
|
||||
"rate_response": USER_PERMISSIONS_CHAT_RATE_RESPONSE,
|
||||
"edit": USER_PERMISSIONS_CHAT_EDIT,
|
||||
"share": USER_PERMISSIONS_CHAT_SHARE,
|
||||
"export": USER_PERMISSIONS_CHAT_EXPORT,
|
||||
|
|
|
|||
|
|
@ -146,6 +146,10 @@ class ChatPermissions(BaseModel):
|
|||
params: bool = True
|
||||
file_upload: bool = True
|
||||
delete: bool = True
|
||||
delete_message: bool = True
|
||||
continue_response: bool = True
|
||||
regenerate_response: bool = True
|
||||
rate_response: bool = True
|
||||
edit: bool = True
|
||||
share: bool = True
|
||||
export: bool = True
|
||||
|
|
|
|||
|
|
@ -71,6 +71,10 @@
|
|||
params: true,
|
||||
file_upload: true,
|
||||
delete: true,
|
||||
delete_message: true,
|
||||
continue_response: true,
|
||||
regenerate_response: true,
|
||||
rate_response: true,
|
||||
edit: true,
|
||||
share: true,
|
||||
export: true,
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@
|
|||
params: true,
|
||||
file_upload: true,
|
||||
delete: true,
|
||||
delete_message: true,
|
||||
continue_response: true,
|
||||
regenerate_response: true,
|
||||
rate_response: true,
|
||||
edit: true,
|
||||
share: true,
|
||||
export: true,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@
|
|||
params: true,
|
||||
file_upload: true,
|
||||
delete: true,
|
||||
delete_message: true,
|
||||
continue_response: true,
|
||||
regenerate_response: true,
|
||||
rate_response: true,
|
||||
edit: true,
|
||||
share: true,
|
||||
export: true,
|
||||
|
|
@ -292,6 +296,14 @@
|
|||
</div>
|
||||
{/if}
|
||||
|
||||
<div class=" flex w-full justify-between my-2 pr-2">
|
||||
<div class=" self-center text-xs font-medium">
|
||||
{$i18n.t('Allow Chat Edit')}
|
||||
</div>
|
||||
|
||||
<Switch bind:state={permissions.chat.edit} />
|
||||
</div>
|
||||
|
||||
<div class=" flex w-full justify-between my-2 pr-2">
|
||||
<div class=" self-center text-xs font-medium">
|
||||
{$i18n.t('Allow Chat Delete')}
|
||||
|
|
@ -302,10 +314,34 @@
|
|||
|
||||
<div class=" flex w-full justify-between my-2 pr-2">
|
||||
<div class=" self-center text-xs font-medium">
|
||||
{$i18n.t('Allow Chat Edit')}
|
||||
{$i18n.t('Allow Delete Messages')}
|
||||
</div>
|
||||
|
||||
<Switch bind:state={permissions.chat.edit} />
|
||||
<Switch bind:state={permissions.chat.delete_message} />
|
||||
</div>
|
||||
|
||||
<div class=" flex w-full justify-between my-2 pr-2">
|
||||
<div class=" self-center text-xs font-medium">
|
||||
{$i18n.t('Allow Continue Response')}
|
||||
</div>
|
||||
|
||||
<Switch bind:state={permissions.chat.continue_response} />
|
||||
</div>
|
||||
|
||||
<div class=" flex w-full justify-between my-2 pr-2">
|
||||
<div class=" self-center text-xs font-medium">
|
||||
{$i18n.t('Allow Response Regeneration')}
|
||||
</div>
|
||||
|
||||
<Switch bind:state={permissions.chat.regenerate_response} />
|
||||
</div>
|
||||
|
||||
<div class=" flex w-full justify-between my-2 pr-2">
|
||||
<div class=" self-center text-xs font-medium">
|
||||
{$i18n.t('Allow Response Rating')}
|
||||
</div>
|
||||
|
||||
<Switch bind:state={permissions.chat.rating_response} />
|
||||
</div>
|
||||
|
||||
<div class=" flex w-full justify-between my-2 pr-2">
|
||||
|
|
|
|||
|
|
@ -1227,7 +1227,7 @@
|
|||
{/if}
|
||||
|
||||
{#if !readOnly}
|
||||
{#if !$temporaryChatEnabled && ($config?.features.enable_message_rating ?? true)}
|
||||
{#if !$temporaryChatEnabled && ($config?.features.enable_message_rating ?? true) && ($user?.role === 'admin' || ($user?.permissions?.chat?.rate_response ?? true))}
|
||||
<Tooltip content={$i18n.t('Good Response')} placement="bottom">
|
||||
<button
|
||||
aria-label={$i18n.t('Good Response')}
|
||||
|
|
@ -1305,7 +1305,7 @@
|
|||
</Tooltip>
|
||||
{/if}
|
||||
|
||||
{#if isLastMessage}
|
||||
{#if isLastMessage && ($user?.role === 'admin' || ($user?.permissions?.chat?.continue_response ?? true))}
|
||||
<Tooltip content={$i18n.t('Continue Response')} placement="bottom">
|
||||
<button
|
||||
aria-label={$i18n.t('Continue Response')}
|
||||
|
|
@ -1342,6 +1342,7 @@
|
|||
</Tooltip>
|
||||
{/if}
|
||||
|
||||
{#if $user?.role === 'admin' || ($user?.permissions?.chat?.regenerate_response ?? false)}
|
||||
{#if $settings?.regenerateMenu ?? true}
|
||||
<button
|
||||
type="button"
|
||||
|
|
@ -1450,7 +1451,9 @@
|
|||
</button>
|
||||
</Tooltip>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if $user?.role === 'admin' || ($user?.permissions?.chat?.delete_message ?? false)}
|
||||
{#if siblings.length > 1}
|
||||
<Tooltip content={$i18n.t('Delete')} placement="bottom">
|
||||
<button
|
||||
|
|
@ -1482,6 +1485,7 @@
|
|||
</button>
|
||||
</Tooltip>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if isLastMessage}
|
||||
{#each model?.actions ?? [] as action}
|
||||
|
|
|
|||
|
|
@ -495,6 +495,7 @@
|
|||
</Tooltip>
|
||||
{/if}
|
||||
|
||||
{#if $_user?.role === 'admin' || ($_user?.permissions?.chat?.delete_message ?? false)}
|
||||
{#if !readOnly && (!isFirstMessage || siblings.length > 1)}
|
||||
<Tooltip content={$i18n.t('Delete')} placement="bottom">
|
||||
<button
|
||||
|
|
@ -522,6 +523,7 @@
|
|||
</button>
|
||||
</Tooltip>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if $settings?.chatBubble ?? true}
|
||||
{#if siblings.length > 1}
|
||||
|
|
|
|||
Loading…
Reference in a new issue