mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac
This commit is contained in:
parent
f264d82d13
commit
9ddb16345f
@ -137,7 +137,7 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ConfigureModelsModal bind:show={showConfigModal} {init} />
|
<ConfigureModelsModal bind:show={showConfigModal} initHandler={init} />
|
||||||
|
|
||||||
{#if models !== null}
|
{#if models !== null}
|
||||||
{#if selectedModelId === null}
|
{#if selectedModelId === null}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import Plus from '$lib/components/icons/Plus.svelte';
|
import Plus from '$lib/components/icons/Plus.svelte';
|
||||||
|
|
||||||
export let show = false;
|
export let show = false;
|
||||||
export let init = () => {};
|
export let initHandler = () => {};
|
||||||
|
|
||||||
let config = null;
|
let config = null;
|
||||||
|
|
||||||
@ -29,26 +29,11 @@
|
|||||||
let loading = false;
|
let loading = false;
|
||||||
let showResetModal = false;
|
let showResetModal = false;
|
||||||
|
|
||||||
const submitHandler = async () => {
|
$: if (show) {
|
||||||
loading = true;
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
const res = await setModelsConfig(localStorage.token, {
|
const init = async () => {
|
||||||
DEFAULT_MODELS: defaultModelIds.join(','),
|
|
||||||
MODEL_ORDER_LIST: modelIds
|
|
||||||
});
|
|
||||||
|
|
||||||
if (res) {
|
|
||||||
toast.success($i18n.t('Models configuration saved successfully'));
|
|
||||||
init();
|
|
||||||
show = false;
|
|
||||||
} else {
|
|
||||||
toast.error($i18n.t('Failed to save models configuration'));
|
|
||||||
}
|
|
||||||
|
|
||||||
loading = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
onMount(async () => {
|
|
||||||
config = await getModelsConfig(localStorage.token);
|
config = await getModelsConfig(localStorage.token);
|
||||||
|
|
||||||
if (config?.DEFAULT_MODELS) {
|
if (config?.DEFAULT_MODELS) {
|
||||||
@ -68,6 +53,28 @@
|
|||||||
// Add remaining IDs not in MODEL_ORDER_LIST, sorted alphabetically
|
// Add remaining IDs not in MODEL_ORDER_LIST, sorted alphabetically
|
||||||
...allModelIds.filter((id) => !orderedSet.has(id)).sort((a, b) => a.localeCompare(b))
|
...allModelIds.filter((id) => !orderedSet.has(id)).sort((a, b) => a.localeCompare(b))
|
||||||
];
|
];
|
||||||
|
};
|
||||||
|
const submitHandler = async () => {
|
||||||
|
loading = true;
|
||||||
|
|
||||||
|
const res = await setModelsConfig(localStorage.token, {
|
||||||
|
DEFAULT_MODELS: defaultModelIds.join(','),
|
||||||
|
MODEL_ORDER_LIST: modelIds
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
toast.success($i18n.t('Models configuration saved successfully'));
|
||||||
|
initHandler();
|
||||||
|
show = false;
|
||||||
|
} else {
|
||||||
|
toast.error($i18n.t('Failed to save models configuration'));
|
||||||
|
}
|
||||||
|
|
||||||
|
loading = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
init();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -79,7 +86,7 @@
|
|||||||
const res = deleteAllModels(localStorage.token);
|
const res = deleteAllModels(localStorage.token);
|
||||||
if (res) {
|
if (res) {
|
||||||
toast.success($i18n.t('All models deleted successfully'));
|
toast.success($i18n.t('All models deleted successfully'));
|
||||||
init();
|
initHandler();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user