From 4af5b21d56c24ee3ae86b28998917dba37a7cfc7 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Thu, 12 Oct 2023 18:18:07 -0700 Subject: [PATCH] set default model button added --- src/routes/+page.svelte | 62 ++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 033b43888..c90742d9a 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -6,16 +6,30 @@ import type { PageData } from './$types'; import { ENDPOINT } from '$lib/contants'; - import { tick } from 'svelte'; + import { onMount, tick } from 'svelte'; export let data: PageData; $: ({ models } = data); let textareaElement; let selectedModel = ''; + let systemPrompt = ''; + let temperature = ''; let prompt = ''; let messages = []; + onMount(() => { + let settings = localStorage.getItem('settings'); + if (settings) { + settings = JSON.parse(settings); + console.log(settings); + + selectedModel = settings.model ?? ''; + systemPrompt = settings.systemPrompt ?? ''; + temperature = settings.temperature ?? ''; + } + }); + ////////////////////////// // Helper functions ////////////////////////// @@ -71,6 +85,22 @@ ); }; + ////////////////////////// + // Web functions + ////////////////////////// + + const saveDefaultModel = () => { + let settings = localStorage.getItem('settings') ?? '{}'; + if (settings) { + settings = JSON.parse(settings); + settings.model = selectedModel; + localStorage.setItem('settings', JSON.stringify(settings)); + } + + console.log('saved'); + toast.success('Default model updated'); + }; + ////////////////////////// // Ollama functions ////////////////////////// @@ -248,18 +278,24 @@
- +
+ +
+ +
+
@@ -358,7 +394,7 @@ {#if messages.length != 0 && messages.at(-1).role == 'assistant' && messages.at(-1).done == true}