forked from open-webui/open-webui
fix(model-selector): prevent saving empty default model
- throw a toast error when user is trying to click on `set as default` without actually choosing the model(s). - feat: added hmr for local development. use `npm run dev` and you get the hmr when debugging.
This commit is contained in:
parent
72524272f0
commit
4d3754980d
2 changed files with 10 additions and 2 deletions
|
@ -6,6 +6,11 @@
|
||||||
export let disabled = false;
|
export let disabled = false;
|
||||||
|
|
||||||
const saveDefaultModel = () => {
|
const saveDefaultModel = () => {
|
||||||
|
const hasEmptyModel = selectedModels.filter(it => it === '');
|
||||||
|
if(hasEmptyModel.length){
|
||||||
|
toast.error('Choose a model before saving...');
|
||||||
|
return;
|
||||||
|
}
|
||||||
settings.set({ ...$settings, models: selectedModels });
|
settings.set({ ...$settings, models: selectedModels });
|
||||||
localStorage.setItem('settings', JSON.stringify($settings));
|
localStorage.setItem('settings', JSON.stringify($settings));
|
||||||
toast.success('Default model updated');
|
toast.success('Default model updated');
|
||||||
|
@ -21,7 +26,7 @@
|
||||||
bind:value={selectedModel}
|
bind:value={selectedModel}
|
||||||
{disabled}
|
{disabled}
|
||||||
>
|
>
|
||||||
<option class=" text-gray-700" value="" selected>Select a model</option>
|
<option class=" text-gray-700" value="" selected disabled>Select a model</option>
|
||||||
|
|
||||||
{#each $models as model}
|
{#each $models as model}
|
||||||
{#if model.name === 'hr'}
|
{#if model.name === 'hr'}
|
||||||
|
|
|
@ -2,5 +2,8 @@ import { sveltekit } from '@sveltejs/kit/vite';
|
||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [sveltekit()]
|
plugins: [sveltekit()],
|
||||||
|
server: {
|
||||||
|
hmr: true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue