From 1c0cc16f8c5198ada5d09d52edf9a8ddf1c52605 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sat, 2 Dec 2023 14:47:23 -0800 Subject: [PATCH 01/15] feat: more advanced params added --- .../components/chat/Settings/Advanced.svelte | 480 ++++++++++++++++++ src/lib/components/chat/SettingsModal.svelte | 320 +++--------- src/routes/(app)/+page.svelte | 14 +- src/routes/(app)/c/[id]/+page.svelte | 14 +- 4 files changed, 556 insertions(+), 272 deletions(-) create mode 100644 src/lib/components/chat/Settings/Advanced.svelte diff --git a/src/lib/components/chat/Settings/Advanced.svelte b/src/lib/components/chat/Settings/Advanced.svelte new file mode 100644 index 000000000..b65ab3be5 --- /dev/null +++ b/src/lib/components/chat/Settings/Advanced.svelte @@ -0,0 +1,480 @@ + + +
+
+
+
Seed
+
+ +
+
+
+ +
+
+
Stop Sequence
+
+ +
+
+
+ +
+
+
Temperature
+ + +
+ + {#if options.temperature !== ''} +
+
+ +
+
+ +
+
+ {/if} +
+ +
+
+
Mirostat
+ + +
+ + {#if options.mirostat !== ''} +
+
+ +
+
+ +
+
+ {/if} +
+ +
+
+
Mirostat Eta
+ + +
+ + {#if options.mirostat_eta !== ''} +
+
+ +
+
+ +
+
+ {/if} +
+ +
+
+
Mirostat Tau
+ + +
+ + {#if options.mirostat_tau !== ''} +
+
+ +
+
+ +
+
+ {/if} +
+ +
+
+
Top K
+ + +
+ + {#if options.top_k !== ''} +
+
+ +
+
+ +
+
+ {/if} +
+ +
+
+
Top P
+ + +
+ + {#if options.top_p !== ''} +
+
+ +
+
+ +
+
+ {/if} +
+ +
+
+
Repeat Penalty
+ + +
+ + {#if options.repeat_penalty !== ''} +
+
+ +
+
+ +
+
+ {/if} +
+ +
+
+
Repeat Last N
+ + +
+ + {#if options.repeat_last_n !== ''} +
+
+ +
+
+ +
+
+ {/if} +
+ +
+
+
Tfs Z
+ + +
+ + {#if options.tfs_z !== ''} +
+
+ +
+
+ +
+
+ {/if} +
+ +
+
+
Context Length
+ + +
+ + {#if options.num_ctx !== ''} +
+
+ +
+
+ +
+
+ {/if} +
+
diff --git a/src/lib/components/chat/SettingsModal.svelte b/src/lib/components/chat/SettingsModal.svelte index 31da70fea..844a31534 100644 --- a/src/lib/components/chat/SettingsModal.svelte +++ b/src/lib/components/chat/SettingsModal.svelte @@ -6,6 +6,7 @@ import { onMount } from 'svelte'; import { config, models, settings, user } from '$lib/stores'; import { splitStream, getGravatarURL } from '$lib/utils'; + import Advanced from './Settings/Advanced.svelte'; export let show = false; @@ -25,12 +26,21 @@ // Advanced let requestFormat = ''; - let seed = 0; - let temperature = ''; - let repeat_penalty = ''; - let top_k = ''; - let top_p = ''; - let num_ctx = ''; + let options = { + // Advanced + seed: 0, + temperature: '', + repeat_penalty: '', + repeat_last_n: '', + mirostat: '', + mirostat_eta: '', + mirostat_tau: '', + top_k: '', + top_p: '', + stop: '', + tfs_z: '', + num_ctx: '' + }; // Models let modelTag = ''; @@ -218,28 +228,6 @@ models.set(await getModels()); }; - $: if (show) { - let settings = JSON.parse(localStorage.getItem('settings') ?? '{}'); - console.log(settings); - - theme = localStorage.theme ?? 'dark'; - API_BASE_URL = settings.API_BASE_URL ?? OLLAMA_API_BASE_URL; - system = settings.system ?? ''; - - requestFormat = settings.requestFormat ?? ''; - seed = settings.seed ?? 0; - temperature = settings.temperature ?? ''; - repeat_penalty = settings.repeat_penalty ?? ''; - top_k = settings.top_k ?? ''; - top_p = settings.top_p ?? ''; - num_ctx = settings.num_ctx ?? ''; - - titleAutoGenerate = settings.titleAutoGenerate ?? true; - speechAutoSend = settings.speechAutoSend ?? false; - gravatarEmail = settings.gravatarEmail ?? ''; - OPENAI_API_KEY = settings.OPENAI_API_KEY ?? ''; - } - const getModels = async (url = '', type = 'all') => { let models = []; const res = await fetch(`${url ? url : $settings?.API_BASE_URL ?? OLLAMA_API_BASE_URL}/tags`, { @@ -306,6 +294,26 @@ onMount(() => { let settings = JSON.parse(localStorage.getItem('settings') ?? '{}'); + console.log(settings); + + theme = localStorage.theme ?? 'dark'; + API_BASE_URL = settings.API_BASE_URL ?? OLLAMA_API_BASE_URL; + system = settings.system ?? ''; + + requestFormat = settings.requestFormat ?? ''; + + options.seed = settings.seed ?? 0; + options.temperature = settings.temperature ?? ''; + options.repeat_penalty = settings.repeat_penalty ?? ''; + options.top_k = settings.top_k ?? ''; + options.top_p = settings.top_p ?? ''; + options.num_ctx = settings.num_ctx ?? ''; + options = { ...options, ...settings.options }; + + titleAutoGenerate = settings.titleAutoGenerate ?? true; + speechAutoSend = settings.speechAutoSend ?? false; + gravatarEmail = settings.gravatarEmail ?? ''; + OPENAI_API_KEY = settings.OPENAI_API_KEY ?? ''; authEnabled = settings.authHeader !== undefined ? true : false; if (authEnabled) { @@ -497,7 +505,7 @@
About
-
+
{#if selectedTab === 'general'}
@@ -612,234 +620,11 @@
{:else if selectedTab === 'advanced'} -
-
-
-
-
Seed
-
- -
-
-
- -
-
-
Temperature
- - -
- - {#if temperature !== ''} -
-
- -
-
- -
-
- {/if} -
- -
-
-
Repeat Penalty
- - -
- - {#if repeat_penalty !== ''} -
-
- -
-
- -
-
- {/if} -
- -
-
-
Top K
- - -
- - {#if top_k !== ''} -
-
- -
-
- -
-
- {/if} -
- -
-
-
Top P
- - -
- - {#if top_p !== ''} -
-
- -
-
- -
-
- {/if} -
- -
-
-
Context Length
- - -
- - {#if num_ctx !== ''} -
-
- -
-
- -
-
- {/if} -
+
+
+
Parameters
+
@@ -871,17 +656,28 @@
+
@@ -127,7 +127,7 @@
@@ -170,7 +170,7 @@
@@ -213,7 +213,7 @@ @@ -256,7 +256,7 @@ @@ -299,7 +299,7 @@ @@ -342,7 +342,7 @@ @@ -385,7 +385,7 @@ @@ -428,7 +428,7 @@ @@ -471,7 +471,7 @@ diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index 656d3f451..bb54dbc1a 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -24,7 +24,7 @@ let showDropdown = false; - let showDeleteHistoryConfirm = false; + let showDeleteHistoryConfirm = false; onMount(async () => { if (window.innerWidth > 1280) { @@ -121,11 +121,11 @@ - +
@@ -449,91 +449,92 @@
Export
- {#if showDeleteHistoryConfirm} -
-
- - - - Are you sure? -
- -
- - -
-
- {:else} - - {/if} + {#if showDeleteHistoryConfirm} +
+
+ + + + Are you sure? +
+ +
+ + +
+
+ {:else} + + {/if} {#if $user !== undefined}
diff --git a/src/routes/(app)/modelfiles/create/+page.svelte b/src/routes/(app)/modelfiles/create/+page.svelte new file mode 100644 index 000000000..3a2e60fc2 --- /dev/null +++ b/src/routes/(app)/modelfiles/create/+page.svelte @@ -0,0 +1,475 @@ + + +
+
+
+ { + let reader = new FileReader(); + reader.onload = (event) => { + let originalImageUrl = `${event.target.result}`; + + const img = new Image(); + img.src = originalImageUrl; + + img.onload = function () { + const canvas = document.createElement('canvas'); + const ctx = canvas.getContext('2d'); + + // Set canvas dimensions to the original image dimensions + canvas.width = img.width; + canvas.height = img.height; + + // Draw the original image on the canvas + ctx.drawImage(img, 0, 0); + + // Get the base64 representation of the compressed image + const compressedSrc = canvas.toDataURL('image/jpeg', 0.1); + + // Display the compressed image + imageUrl = compressedSrc; + + inputFiles = null; + }; + }; + + if ( + inputFiles && + inputFiles.length > 0 && + ['image/gif', 'image/jpeg', 'image/png'].includes(inputFiles[0]['type']) + ) { + reader.readAsDataURL(inputFiles[0]); + } else { + console.log(`Unsupported File Type '${inputFiles[0]['type']}'.`); + inputFiles = null; + } + }} + /> + +
My Modelfiles
+ + +
+ +
{ + submitHandler(); + }} + > +
+
+ +
+
+ +
+
Name*
+ +
+ +
+
+ +
+
Description*
+ +
+ +
+
+ +
+
+
Modelfile
+ + +
+ + + + {#if raw} +
+
Content*
+ +
+