From 4d3754980dd87bb026dd3cae61f8a6be7c6fbbd4 Mon Sep 17 00:00:00 2001 From: Anuraag Jain Date: Thu, 28 Dec 2023 18:06:17 +0200 Subject: [PATCH] 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. --- src/lib/components/chat/ModelSelector.svelte | 7 ++++++- vite.config.ts | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/components/chat/ModelSelector.svelte b/src/lib/components/chat/ModelSelector.svelte index 890be53a..626755e0 100644 --- a/src/lib/components/chat/ModelSelector.svelte +++ b/src/lib/components/chat/ModelSelector.svelte @@ -6,6 +6,11 @@ export let disabled = false; const saveDefaultModel = () => { + const hasEmptyModel = selectedModels.filter(it => it === ''); + if(hasEmptyModel.length){ + toast.error('Choose a model before saving...'); + return; + } settings.set({ ...$settings, models: selectedModels }); localStorage.setItem('settings', JSON.stringify($settings)); toast.success('Default model updated'); @@ -21,7 +26,7 @@ bind:value={selectedModel} {disabled} > - + {#each $models as model} {#if model.name === 'hr'} diff --git a/vite.config.ts b/vite.config.ts index bbf8c7da..c0c600a5 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,5 +2,8 @@ import { sveltekit } from '@sveltejs/kit/vite'; import { defineConfig } from 'vite'; export default defineConfig({ - plugins: [sveltekit()] + plugins: [sveltekit()], + server: { + hmr: true + } });