mirror of
https://github.com/open-webui/open-webui
synced 2025-05-21 13:36:35 +00:00
refac
This commit is contained in:
parent
2e77d5ef0e
commit
a0df6cce40
@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
import { models, settings, user } from '$lib/stores';
|
import { models, settings, user, config } from '$lib/stores';
|
||||||
import { createEventDispatcher, onMount, getContext, tick } from 'svelte';
|
import { createEventDispatcher, onMount, getContext, tick } from 'svelte';
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
@ -16,16 +16,16 @@
|
|||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
let config = null;
|
let evaluationConfig = null;
|
||||||
let showAddModel = false;
|
let showAddModel = false;
|
||||||
|
|
||||||
const submitHandler = async () => {
|
const submitHandler = async () => {
|
||||||
config = await updateConfig(localStorage.token, config).catch((err) => {
|
evaluationConfig = await updateConfig(localStorage.token, evaluationConfig).catch((err) => {
|
||||||
toast.error(err);
|
toast.error(err);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (config) {
|
if (evaluationConfig) {
|
||||||
toast.success('Settings saved successfully');
|
toast.success('Settings saved successfully');
|
||||||
models.set(
|
models.set(
|
||||||
await getModels(
|
await getModels(
|
||||||
@ -37,8 +37,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const addModelHandler = async (model) => {
|
const addModelHandler = async (model) => {
|
||||||
config.EVALUATION_ARENA_MODELS.push(model);
|
evaluationConfig.EVALUATION_ARENA_MODELS.push(model);
|
||||||
config.EVALUATION_ARENA_MODELS = [...config.EVALUATION_ARENA_MODELS];
|
evaluationConfig.EVALUATION_ARENA_MODELS = [...evaluationConfig.EVALUATION_ARENA_MODELS];
|
||||||
|
|
||||||
await submitHandler();
|
await submitHandler();
|
||||||
models.set(
|
models.set(
|
||||||
@ -50,8 +50,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const editModelHandler = async (model, modelIdx) => {
|
const editModelHandler = async (model, modelIdx) => {
|
||||||
config.EVALUATION_ARENA_MODELS[modelIdx] = model;
|
evaluationConfig.EVALUATION_ARENA_MODELS[modelIdx] = model;
|
||||||
config.EVALUATION_ARENA_MODELS = [...config.EVALUATION_ARENA_MODELS];
|
evaluationConfig.EVALUATION_ARENA_MODELS = [...evaluationConfig.EVALUATION_ARENA_MODELS];
|
||||||
|
|
||||||
await submitHandler();
|
await submitHandler();
|
||||||
models.set(
|
models.set(
|
||||||
@ -63,7 +63,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const deleteModelHandler = async (modelIdx) => {
|
const deleteModelHandler = async (modelIdx) => {
|
||||||
config.EVALUATION_ARENA_MODELS = config.EVALUATION_ARENA_MODELS.filter(
|
evaluationConfig.EVALUATION_ARENA_MODELS = evaluationConfig.EVALUATION_ARENA_MODELS.filter(
|
||||||
(m, mIdx) => mIdx !== modelIdx
|
(m, mIdx) => mIdx !== modelIdx
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if ($user.role === 'admin') {
|
if ($user.role === 'admin') {
|
||||||
config = await getConfig(localStorage.token).catch((err) => {
|
evaluationConfig = await getConfig(localStorage.token).catch((err) => {
|
||||||
toast.error(err);
|
toast.error(err);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@ -101,7 +101,7 @@
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class="overflow-y-scroll scrollbar-hidden h-full">
|
<div class="overflow-y-scroll scrollbar-hidden h-full">
|
||||||
{#if config !== null}
|
{#if evaluationConfig !== null}
|
||||||
<div class="">
|
<div class="">
|
||||||
<div class="text-sm font-medium mb-2">{$i18n.t('General Settings')}</div>
|
<div class="text-sm font-medium mb-2">{$i18n.t('General Settings')}</div>
|
||||||
|
|
||||||
@ -110,12 +110,12 @@
|
|||||||
<div class=" text-xs font-medium">{$i18n.t('Arena Models')}</div>
|
<div class=" text-xs font-medium">{$i18n.t('Arena Models')}</div>
|
||||||
|
|
||||||
<Tooltip content={$i18n.t(`Message rating should be enabled to use this feature`)}>
|
<Tooltip content={$i18n.t(`Message rating should be enabled to use this feature`)}>
|
||||||
<Switch bind:state={config.ENABLE_EVALUATION_ARENA_MODELS} />
|
<Switch bind:state={evaluationConfig.ENABLE_EVALUATION_ARENA_MODELS} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if config.ENABLE_EVALUATION_ARENA_MODELS}
|
{#if evaluationConfig.ENABLE_EVALUATION_ARENA_MODELS}
|
||||||
<hr class=" border-gray-50 dark:border-gray-700/10 my-2" />
|
<hr class=" border-gray-50 dark:border-gray-700/10 my-2" />
|
||||||
|
|
||||||
<div class="flex justify-between items-center mb-2">
|
<div class="flex justify-between items-center mb-2">
|
||||||
@ -137,8 +137,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
{#if (config?.EVALUATION_ARENA_MODELS ?? []).length > 0}
|
{#if (evaluationConfig?.EVALUATION_ARENA_MODELS ?? []).length > 0}
|
||||||
{#each config.EVALUATION_ARENA_MODELS as model, index}
|
{#each evaluationConfig.EVALUATION_ARENA_MODELS as model, index}
|
||||||
<Model
|
<Model
|
||||||
{model}
|
{model}
|
||||||
on:edit={(e) => {
|
on:edit={(e) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user