From 547b990041835578208805340d0b16c9e6f387bc Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 10 Jun 2024 13:29:09 -0700 Subject: [PATCH] refac: params --- .../Settings/Advanced/AdvancedParams.svelte | 320 +++++++++--------- .../components/chat/Settings/General.svelte | 61 ++-- .../workspace/models/create/+page.svelte | 1 + .../(app)/workspace/models/edit/+page.svelte | 1 + 4 files changed, 193 insertions(+), 190 deletions(-) diff --git a/src/lib/components/chat/Settings/Advanced/AdvancedParams.svelte b/src/lib/components/chat/Settings/Advanced/AdvancedParams.svelte index 7d5d77352..92535fa34 100644 --- a/src/lib/components/chat/Settings/Advanced/AdvancedParams.svelte +++ b/src/lib/components/chat/Settings/Advanced/AdvancedParams.svelte @@ -5,21 +5,23 @@ const i18n = getContext('i18n'); + export let admin = false; + export let params = { // Advanced - seed: 0, + seed: null, stop: null, - temperature: '', - frequency_penalty: '', - repeat_last_n: '', - mirostat: '', - mirostat_eta: '', - mirostat_tau: '', - top_k: '', - top_p: '', - tfs_z: '', - num_ctx: '', - max_tokens: '', + temperature: null, + frequency_penalty: null, + repeat_last_n: null, + mirostat: null, + mirostat_eta: null, + mirostat_tau: null, + top_k: null, + top_p: null, + tfs_z: null, + num_ctx: null, + max_tokens: null, use_mmap: null, use_mlock: null, num_thread: null, @@ -112,10 +114,10 @@ class="p-1 px-3 text-xs flex rounded transition" type="button" on:click={() => { - params.temperature = (params?.temperature ?? '') === '' ? 0.8 : ''; + params.temperature = (params?.temperature ?? null) === null ? 0.8 : null; }} > - {#if (params?.temperature ?? '') === ''} + {#if (params?.temperature ?? null) === null} {$i18n.t('Default')} {:else} {$i18n.t('Custom')} @@ -123,7 +125,7 @@ - {#if (params?.temperature ?? '') !== ''} + {#if (params?.temperature ?? null) !== null}
{ - params.mirostat = (params?.mirostat ?? '') === '' ? 0 : ''; + params.mirostat = (params?.mirostat ?? null) === null ? 0 : null; }} > - {#if (params?.mirostat ?? '') === ''} + {#if (params?.mirostat ?? null) === null} {$i18n.t('Default')} {:else} {$i18n.t('Custom')} @@ -168,7 +170,7 @@
- {#if (params?.mirostat ?? '') !== ''} + {#if (params?.mirostat ?? null) !== null}
{ - params.mirostat_eta = (params?.mirostat_eta ?? '') === '' ? 0.1 : ''; + params.mirostat_eta = (params?.mirostat_eta ?? null) === null ? 0.1 : null; }} > - {#if (params?.mirostat_eta ?? '') === ''} + {#if (params?.mirostat_eta ?? null) === null} {$i18n.t('Default')} {:else} {$i18n.t('Custom')} @@ -214,7 +216,7 @@
- {#if (params?.mirostat_eta ?? '') !== ''} + {#if (params?.mirostat_eta ?? null) !== null}
{ - params.mirostat_tau = (params?.mirostat_tau ?? '') === '' ? 5.0 : ''; + params.mirostat_tau = (params?.mirostat_tau ?? null) === null ? 5.0 : null; }} > - {#if (params?.mirostat_tau ?? '') === ''} + {#if (params?.mirostat_tau ?? null) === null} {$i18n.t('Default')} {:else} {$i18n.t('Custom')} @@ -259,7 +261,7 @@
- {#if (params?.mirostat_tau ?? '') !== ''} + {#if (params?.mirostat_tau ?? null) !== null}
{ - params.top_k = (params?.top_k ?? '') === '' ? 40 : ''; + params.top_k = (params?.top_k ?? null) === null ? 40 : null; }} > - {#if (params?.top_k ?? '') === ''} + {#if (params?.top_k ?? null) === null} {$i18n.t('Default')} {:else} {$i18n.t('Custom')} @@ -304,7 +306,7 @@
- {#if (params?.top_k ?? '') !== ''} + {#if (params?.top_k ?? null) !== null}
{ - params.top_p = (params?.top_p ?? '') === '' ? 0.9 : ''; + params.top_p = (params?.top_p ?? null) === null ? 0.9 : null; }} > - {#if (params?.top_p ?? '') === ''} + {#if (params?.top_p ?? null) === null} {$i18n.t('Default')} {:else} {$i18n.t('Custom')} @@ -349,7 +351,7 @@
- {#if (params?.top_p ?? '') !== ''} + {#if (params?.top_p ?? null) !== null}
{ - params.frequency_penalty = (params?.frequency_penalty ?? '') === '' ? 1.1 : ''; + params.frequency_penalty = (params?.frequency_penalty ?? null) === null ? 1.1 : null; }} > - {#if (params?.frequency_penalty ?? '') === ''} + {#if (params?.frequency_penalty ?? null) === null} {$i18n.t('Default')} {:else} {$i18n.t('Custom')} @@ -394,7 +396,7 @@
- {#if (params?.frequency_penalty ?? '') !== ''} + {#if (params?.frequency_penalty ?? null) !== null}
{ - params.repeat_last_n = (params?.repeat_last_n ?? '') === '' ? 64 : ''; + params.repeat_last_n = (params?.repeat_last_n ?? null) === null ? 64 : null; }} > - {#if (params?.repeat_last_n ?? '') === ''} + {#if (params?.repeat_last_n ?? null) === null} {$i18n.t('Default')} {:else} {$i18n.t('Custom')} @@ -439,7 +441,7 @@
- {#if (params?.repeat_last_n ?? '') !== ''} + {#if (params?.repeat_last_n ?? null) !== null}
{ - params.tfs_z = (params?.tfs_z ?? '') === '' ? 1 : ''; + params.tfs_z = (params?.tfs_z ?? null) === null ? 1 : null; }} > - {#if (params?.tfs_z ?? '') === ''} + {#if (params?.tfs_z ?? null) === null} {$i18n.t('Default')} {:else} {$i18n.t('Custom')} @@ -485,7 +487,7 @@
- {#if (params?.tfs_z ?? '') !== ''} + {#if (params?.tfs_z ?? null) !== null}
{ - params.num_ctx = (params?.num_ctx ?? '') === '' ? 2048 : ''; + params.num_ctx = (params?.num_ctx ?? null) === null ? 2048 : null; }} > - {#if (params?.num_ctx ?? '') === ''} + {#if (params?.num_ctx ?? null) === null} {$i18n.t('Default')} {:else} {$i18n.t('Custom')} @@ -530,7 +532,7 @@
- {#if (params?.num_ctx ?? '') !== ''} + {#if (params?.num_ctx ?? null) !== null}
{ - params.max_tokens = (params?.max_tokens ?? '') === '' ? 128 : ''; + params.max_tokens = (params?.max_tokens ?? null) === null ? 128 : null; }} > - {#if (params?.max_tokens ?? '') === ''} + {#if (params?.max_tokens ?? null) === null} {$i18n.t('Default')} {:else} {$i18n.t('Custom')} @@ -575,7 +577,7 @@
- {#if (params?.max_tokens ?? '') !== ''} + {#if (params?.max_tokens ?? null) !== null}
-
-
-
{$i18n.t('use_mmap (Ollama)')}
+ {#if admin} +
+
+
{$i18n.t('use_mmap (Ollama)')}
- -
-
- -
-
-
{$i18n.t('use_mlock (Ollama)')}
- - -
-
- -
-
-
{$i18n.t('num_thread (Ollama)')}
- - -
- - {#if (params?.num_thread ?? null) !== null} -
-
- -
-
- -
+
- {/if} -
- -
-
-
{$i18n.t('Template')}
- -
- {#if (params?.template ?? null) !== null} -
-
-