mirror of
https://github.com/open-webui/open-webui
synced 2025-06-16 19:31:52 +00:00
enh: enable message rating setting
This commit is contained in:
parent
5abe1076ed
commit
0fa85c5c64
@ -43,6 +43,7 @@ from config import (
|
|||||||
JWT_EXPIRES_IN,
|
JWT_EXPIRES_IN,
|
||||||
WEBUI_BANNERS,
|
WEBUI_BANNERS,
|
||||||
ENABLE_COMMUNITY_SHARING,
|
ENABLE_COMMUNITY_SHARING,
|
||||||
|
ENABLE_MESSAGE_RATING,
|
||||||
AppConfig,
|
AppConfig,
|
||||||
OAUTH_USERNAME_CLAIM,
|
OAUTH_USERNAME_CLAIM,
|
||||||
OAUTH_PICTURE_CLAIM,
|
OAUTH_PICTURE_CLAIM,
|
||||||
@ -81,6 +82,7 @@ app.state.config.WEBHOOK_URL = WEBHOOK_URL
|
|||||||
app.state.config.BANNERS = WEBUI_BANNERS
|
app.state.config.BANNERS = WEBUI_BANNERS
|
||||||
|
|
||||||
app.state.config.ENABLE_COMMUNITY_SHARING = ENABLE_COMMUNITY_SHARING
|
app.state.config.ENABLE_COMMUNITY_SHARING = ENABLE_COMMUNITY_SHARING
|
||||||
|
app.state.config.ENABLE_MESSAGE_RATING = ENABLE_MESSAGE_RATING
|
||||||
|
|
||||||
app.state.config.OAUTH_USERNAME_CLAIM = OAUTH_USERNAME_CLAIM
|
app.state.config.OAUTH_USERNAME_CLAIM = OAUTH_USERNAME_CLAIM
|
||||||
app.state.config.OAUTH_PICTURE_CLAIM = OAUTH_PICTURE_CLAIM
|
app.state.config.OAUTH_PICTURE_CLAIM = OAUTH_PICTURE_CLAIM
|
||||||
|
@ -352,6 +352,7 @@ async def get_admin_config(request: Request, user=Depends(get_admin_user)):
|
|||||||
"DEFAULT_USER_ROLE": request.app.state.config.DEFAULT_USER_ROLE,
|
"DEFAULT_USER_ROLE": request.app.state.config.DEFAULT_USER_ROLE,
|
||||||
"JWT_EXPIRES_IN": request.app.state.config.JWT_EXPIRES_IN,
|
"JWT_EXPIRES_IN": request.app.state.config.JWT_EXPIRES_IN,
|
||||||
"ENABLE_COMMUNITY_SHARING": request.app.state.config.ENABLE_COMMUNITY_SHARING,
|
"ENABLE_COMMUNITY_SHARING": request.app.state.config.ENABLE_COMMUNITY_SHARING,
|
||||||
|
"ENABLE_MESSAGE_RATING": request.app.state.config.ENABLE_MESSAGE_RATING,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -361,6 +362,7 @@ class AdminConfig(BaseModel):
|
|||||||
DEFAULT_USER_ROLE: str
|
DEFAULT_USER_ROLE: str
|
||||||
JWT_EXPIRES_IN: str
|
JWT_EXPIRES_IN: str
|
||||||
ENABLE_COMMUNITY_SHARING: bool
|
ENABLE_COMMUNITY_SHARING: bool
|
||||||
|
ENABLE_MESSAGE_RATING: bool
|
||||||
|
|
||||||
|
|
||||||
@router.post("/admin/config")
|
@router.post("/admin/config")
|
||||||
@ -382,6 +384,7 @@ async def update_admin_config(
|
|||||||
request.app.state.config.ENABLE_COMMUNITY_SHARING = (
|
request.app.state.config.ENABLE_COMMUNITY_SHARING = (
|
||||||
form_data.ENABLE_COMMUNITY_SHARING
|
form_data.ENABLE_COMMUNITY_SHARING
|
||||||
)
|
)
|
||||||
|
request.app.state.config.ENABLE_MESSAGE_RATING = form_data.ENABLE_MESSAGE_RATING
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"SHOW_ADMIN_DETAILS": request.app.state.config.SHOW_ADMIN_DETAILS,
|
"SHOW_ADMIN_DETAILS": request.app.state.config.SHOW_ADMIN_DETAILS,
|
||||||
@ -389,6 +392,7 @@ async def update_admin_config(
|
|||||||
"DEFAULT_USER_ROLE": request.app.state.config.DEFAULT_USER_ROLE,
|
"DEFAULT_USER_ROLE": request.app.state.config.DEFAULT_USER_ROLE,
|
||||||
"JWT_EXPIRES_IN": request.app.state.config.JWT_EXPIRES_IN,
|
"JWT_EXPIRES_IN": request.app.state.config.JWT_EXPIRES_IN,
|
||||||
"ENABLE_COMMUNITY_SHARING": request.app.state.config.ENABLE_COMMUNITY_SHARING,
|
"ENABLE_COMMUNITY_SHARING": request.app.state.config.ENABLE_COMMUNITY_SHARING,
|
||||||
|
"ENABLE_MESSAGE_RATING": request.app.state.config.ENABLE_MESSAGE_RATING,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -842,6 +842,12 @@ ENABLE_COMMUNITY_SHARING = PersistentConfig(
|
|||||||
os.environ.get("ENABLE_COMMUNITY_SHARING", "True").lower() == "true",
|
os.environ.get("ENABLE_COMMUNITY_SHARING", "True").lower() == "true",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ENABLE_MESSAGE_RATING = PersistentConfig(
|
||||||
|
"ENABLE_MESSAGE_RATING",
|
||||||
|
"ui.enable_message_rating",
|
||||||
|
os.environ.get("ENABLE_MESSAGE_RATING", "True").lower() == "true",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def validate_cors_origins(origins):
|
def validate_cors_origins(origins):
|
||||||
for origin in origins:
|
for origin in origins:
|
||||||
|
@ -1973,6 +1973,7 @@ async def get_app_config():
|
|||||||
"enable_web_search": rag_app.state.config.ENABLE_RAG_WEB_SEARCH,
|
"enable_web_search": rag_app.state.config.ENABLE_RAG_WEB_SEARCH,
|
||||||
"enable_image_generation": images_app.state.config.ENABLED,
|
"enable_image_generation": images_app.state.config.ENABLED,
|
||||||
"enable_community_sharing": webui_app.state.config.ENABLE_COMMUNITY_SHARING,
|
"enable_community_sharing": webui_app.state.config.ENABLE_COMMUNITY_SHARING,
|
||||||
|
"enable_message_rating": webui_app.state.config.ENABLE_MESSAGE_RATING,
|
||||||
"enable_admin_export": ENABLE_ADMIN_EXPORT,
|
"enable_admin_export": ENABLE_ADMIN_EXPORT,
|
||||||
"enable_admin_chat_access": ENABLE_ADMIN_CHAT_ACCESS,
|
"enable_admin_chat_access": ENABLE_ADMIN_CHAT_ACCESS,
|
||||||
},
|
},
|
||||||
|
@ -336,8 +336,11 @@
|
|||||||
<div class="flex-1 mt-3 lg:mt-0 overflow-y-scroll">
|
<div class="flex-1 mt-3 lg:mt-0 overflow-y-scroll">
|
||||||
{#if selectedTab === 'general'}
|
{#if selectedTab === 'general'}
|
||||||
<General
|
<General
|
||||||
saveHandler={() => {
|
saveHandler={async () => {
|
||||||
toast.success($i18n.t('Settings saved successfully!'));
|
toast.success($i18n.t('Settings saved successfully!'));
|
||||||
|
|
||||||
|
await tick();
|
||||||
|
await config.set(await getBackendConfig());
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{:else if selectedTab === 'users'}
|
{:else if selectedTab === 'users'}
|
||||||
|
@ -1,22 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import { getBackendConfig, getWebhookUrl, updateWebhookUrl } from '$lib/apis';
|
||||||
getCommunitySharingEnabledStatus,
|
import { getAdminConfig, updateAdminConfig } from '$lib/apis/auths';
|
||||||
getWebhookUrl,
|
|
||||||
toggleCommunitySharingEnabledStatus,
|
|
||||||
updateWebhookUrl
|
|
||||||
} from '$lib/apis';
|
|
||||||
import {
|
|
||||||
getAdminConfig,
|
|
||||||
getDefaultUserRole,
|
|
||||||
getJWTExpiresDuration,
|
|
||||||
getSignUpEnabledStatus,
|
|
||||||
toggleSignUpEnabledStatus,
|
|
||||||
updateAdminConfig,
|
|
||||||
updateDefaultUserRole,
|
|
||||||
updateJWTExpiresDuration
|
|
||||||
} from '$lib/apis/auths';
|
|
||||||
import Switch from '$lib/components/common/Switch.svelte';
|
import Switch from '$lib/components/common/Switch.svelte';
|
||||||
|
import { config } from '$lib/stores';
|
||||||
import { onMount, getContext } from 'svelte';
|
import { onMount, getContext } from 'svelte';
|
||||||
|
import { toast } from 'svelte-sonner';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
@ -30,7 +18,7 @@
|
|||||||
const res = await updateAdminConfig(localStorage.token, adminConfig);
|
const res = await updateAdminConfig(localStorage.token, adminConfig);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
toast.success(i18n.t('Settings updated successfully'));
|
saveHandler();
|
||||||
} else {
|
} else {
|
||||||
toast.error(i18n.t('Failed to update settings'));
|
toast.error(i18n.t('Failed to update settings'));
|
||||||
}
|
}
|
||||||
@ -51,9 +39,8 @@
|
|||||||
|
|
||||||
<form
|
<form
|
||||||
class="flex flex-col h-full justify-between space-y-3 text-sm"
|
class="flex flex-col h-full justify-between space-y-3 text-sm"
|
||||||
on:submit|preventDefault={() => {
|
on:submit|preventDefault={async () => {
|
||||||
updateHandler();
|
updateHandler();
|
||||||
saveHandler();
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class=" space-y-3 overflow-y-scroll scrollbar-hidden h-full">
|
<div class=" space-y-3 overflow-y-scroll scrollbar-hidden h-full">
|
||||||
@ -98,6 +85,12 @@
|
|||||||
<Switch bind:state={adminConfig.ENABLE_COMMUNITY_SHARING} />
|
<Switch bind:state={adminConfig.ENABLE_COMMUNITY_SHARING} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="my-3 flex w-full items-center justify-between pr-2">
|
||||||
|
<div class=" self-center text-xs font-medium">{$i18n.t('Enable Message Rating')}</div>
|
||||||
|
|
||||||
|
<Switch bind:state={adminConfig.ENABLE_MESSAGE_RATING} />
|
||||||
|
</div>
|
||||||
|
|
||||||
<hr class=" dark:border-gray-850 my-2" />
|
<hr class=" dark:border-gray-850 my-2" />
|
||||||
|
|
||||||
<div class=" w-full justify-between">
|
<div class=" w-full justify-between">
|
||||||
|
@ -719,6 +719,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if !readOnly}
|
{#if !readOnly}
|
||||||
|
{#if $config?.features.enable_message_rating ?? true}
|
||||||
<Tooltip content={$i18n.t('Good Response')} placement="bottom">
|
<Tooltip content={$i18n.t('Good Response')} placement="bottom">
|
||||||
<button
|
<button
|
||||||
class="{isLastMessage
|
class="{isLastMessage
|
||||||
@ -816,6 +817,7 @@
|
|||||||
>
|
>
|
||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if isLastMessage}
|
{#if isLastMessage}
|
||||||
<Tooltip content={$i18n.t('Continue Response')} placement="bottom">
|
<Tooltip content={$i18n.t('Continue Response')} placement="bottom">
|
||||||
|
Loading…
Reference in New Issue
Block a user