From 4d3754980dd87bb026dd3cae61f8a6be7c6fbbd4 Mon Sep 17 00:00:00 2001 From: Anuraag Jain Date: Thu, 28 Dec 2023 18:06:17 +0200 Subject: [PATCH 1/2] 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 890be53a6..626755e05 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 bbf8c7da4..c0c600a5a 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 + } }); From 5ee58e1c7963a1772f2cc0d0dfba8a07b8a28963 Mon Sep 17 00:00:00 2001 From: Anuraag Jain Date: Thu, 28 Dec 2023 20:19:09 +0200 Subject: [PATCH 2/2] revert: vite config, hmr works without it --- vite.config.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index c0c600a5a..bbf8c7da4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,8 +2,5 @@ import { sveltekit } from '@sveltejs/kit/vite'; import { defineConfig } from 'vite'; export default defineConfig({ - plugins: [sveltekit()], - server: { - hmr: true - } + plugins: [sveltekit()] });