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