Merge pull request #308 from anuraagdjain/fix/model-saving

fix(model-selector): prevent saving empty default model
This commit is contained in:
Timothy Jaeryang Baek 2023-12-28 13:22:24 -05:00 committed by GitHub
commit 8370465796
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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'}