mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
let requestFormat = '';
|
||||
let keepAlive = null;
|
||||
|
||||
let options = {
|
||||
let params = {
|
||||
// Advanced
|
||||
seed: 0,
|
||||
temperature: '',
|
||||
@@ -44,14 +44,14 @@
|
||||
requestFormat = settings.requestFormat ?? '';
|
||||
keepAlive = settings.keepAlive ?? null;
|
||||
|
||||
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 };
|
||||
options.stop = (settings?.options?.stop ?? []).join(',');
|
||||
params.seed = settings.seed ?? 0;
|
||||
params.temperature = settings.temperature ?? '';
|
||||
params.repeat_penalty = settings.repeat_penalty ?? '';
|
||||
params.top_k = settings.top_k ?? '';
|
||||
params.top_p = settings.top_p ?? '';
|
||||
params.num_ctx = settings.num_ctx ?? '';
|
||||
params = { ...params, ...settings.params };
|
||||
params.stop = (settings?.params?.stop ?? []).join(',');
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<div class=" space-y-3 pr-1.5 overflow-y-scroll max-h-80">
|
||||
<div class=" text-sm font-medium">{$i18n.t('Parameters')}</div>
|
||||
|
||||
<AdvancedParams bind:options />
|
||||
<AdvancedParams bind:params />
|
||||
<hr class=" dark:border-gray-700" />
|
||||
|
||||
<div class=" py-1 w-full justify-between">
|
||||
@@ -128,20 +128,20 @@
|
||||
class=" px-4 py-2 bg-emerald-700 hover:bg-emerald-800 text-gray-100 transition rounded-lg"
|
||||
on:click={() => {
|
||||
saveSettings({
|
||||
options: {
|
||||
seed: (options.seed !== 0 ? options.seed : undefined) ?? undefined,
|
||||
stop: options.stop !== '' ? options.stop.split(',').filter((e) => e) : undefined,
|
||||
temperature: options.temperature !== '' ? options.temperature : undefined,
|
||||
repeat_penalty: options.repeat_penalty !== '' ? options.repeat_penalty : undefined,
|
||||
repeat_last_n: options.repeat_last_n !== '' ? options.repeat_last_n : undefined,
|
||||
mirostat: options.mirostat !== '' ? options.mirostat : undefined,
|
||||
mirostat_eta: options.mirostat_eta !== '' ? options.mirostat_eta : undefined,
|
||||
mirostat_tau: options.mirostat_tau !== '' ? options.mirostat_tau : undefined,
|
||||
top_k: options.top_k !== '' ? options.top_k : undefined,
|
||||
top_p: options.top_p !== '' ? options.top_p : undefined,
|
||||
tfs_z: options.tfs_z !== '' ? options.tfs_z : undefined,
|
||||
num_ctx: options.num_ctx !== '' ? options.num_ctx : undefined,
|
||||
num_predict: options.num_predict !== '' ? options.num_predict : undefined
|
||||
params: {
|
||||
seed: (params.seed !== 0 ? params.seed : undefined) ?? undefined,
|
||||
stop: params.stop !== '' ? params.stop.split(',').filter((e) => e) : undefined,
|
||||
temperature: params.temperature !== '' ? params.temperature : undefined,
|
||||
repeat_penalty: params.repeat_penalty !== '' ? params.repeat_penalty : undefined,
|
||||
repeat_last_n: params.repeat_last_n !== '' ? params.repeat_last_n : undefined,
|
||||
mirostat: params.mirostat !== '' ? params.mirostat : undefined,
|
||||
mirostat_eta: params.mirostat_eta !== '' ? params.mirostat_eta : undefined,
|
||||
mirostat_tau: params.mirostat_tau !== '' ? params.mirostat_tau : undefined,
|
||||
top_k: params.top_k !== '' ? params.top_k : undefined,
|
||||
top_p: params.top_p !== '' ? params.top_p : undefined,
|
||||
tfs_z: params.tfs_z !== '' ? params.tfs_z : undefined,
|
||||
num_ctx: params.num_ctx !== '' ? params.num_ctx : undefined,
|
||||
num_predict: params.num_predict !== '' ? params.num_predict : undefined
|
||||
},
|
||||
keepAlive: keepAlive ? (isNaN(keepAlive) ? keepAlive : parseInt(keepAlive)) : undefined
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
export let options = {
|
||||
export let params = {
|
||||
// Advanced
|
||||
seed: 0,
|
||||
stop: '',
|
||||
@@ -17,40 +17,82 @@
|
||||
top_p: '',
|
||||
tfs_z: '',
|
||||
num_ctx: '',
|
||||
num_predict: ''
|
||||
num_predict: '',
|
||||
template: null
|
||||
};
|
||||
|
||||
let customFieldName = '';
|
||||
let customFieldValue = '';
|
||||
</script>
|
||||
|
||||
<div class=" space-y-3 text-xs">
|
||||
<div>
|
||||
<div class=" py-0.5 flex w-full justify-between">
|
||||
<div class=" w-20 text-xs font-medium self-center">{$i18n.t('Seed')}</div>
|
||||
<div class=" flex-1 self-center">
|
||||
<input
|
||||
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
|
||||
type="number"
|
||||
placeholder="Enter Seed"
|
||||
bind:value={options.seed}
|
||||
autocomplete="off"
|
||||
min="0"
|
||||
/>
|
||||
</div>
|
||||
<div class=" py-0.5 w-full justify-between">
|
||||
<div class="flex w-full justify-between">
|
||||
<div class=" self-center text-xs font-medium">{$i18n.t('Seed')}</div>
|
||||
|
||||
<button
|
||||
class="p-1 px-3 text-xs flex rounded transition"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
params.seed = (params?.seed ?? null) === null ? 0 : null;
|
||||
}}
|
||||
>
|
||||
{#if (params?.seed ?? null) === null}
|
||||
<span class="ml-2 self-center"> {$i18n.t('Default')} </span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if (params?.seed ?? null) !== null}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<input
|
||||
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
|
||||
type="number"
|
||||
placeholder="Enter Seed"
|
||||
bind:value={params.seed}
|
||||
autocomplete="off"
|
||||
min="0"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class=" py-0.5 flex w-full justify-between">
|
||||
<div class=" w-20 text-xs font-medium self-center">{$i18n.t('Stop Sequence')}</div>
|
||||
<div class=" flex-1 self-center">
|
||||
<input
|
||||
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
|
||||
type="text"
|
||||
placeholder={$i18n.t('Enter stop sequence')}
|
||||
bind:value={options.stop}
|
||||
autocomplete="off"
|
||||
/>
|
||||
</div>
|
||||
<div class=" py-0.5 w-full justify-between">
|
||||
<div class="flex w-full justify-between">
|
||||
<div class=" self-center text-xs font-medium">{$i18n.t('Stop Sequence')}</div>
|
||||
|
||||
<button
|
||||
class="p-1 px-3 text-xs flex rounded transition"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
params.stop = (params?.stop ?? null) === null ? '' : null;
|
||||
}}
|
||||
>
|
||||
{#if (params?.stop ?? null) === null}
|
||||
<span class="ml-2 self-center"> {$i18n.t('Default')} </span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if (params?.stop ?? null) !== null}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<input
|
||||
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
|
||||
type="text"
|
||||
placeholder={$i18n.t('Enter stop sequence')}
|
||||
bind:value={params.stop}
|
||||
autocomplete="off"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class=" py-0.5 w-full justify-between">
|
||||
@@ -61,10 +103,10 @@
|
||||
class="p-1 px-3 text-xs flex rounded transition"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
options.temperature = options.temperature === '' ? 0.8 : '';
|
||||
params.temperature = (params?.temperature ?? '') === '' ? 0.8 : '';
|
||||
}}
|
||||
>
|
||||
{#if options.temperature === ''}
|
||||
{#if (params?.temperature ?? '') === ''}
|
||||
<span class="ml-2 self-center"> {$i18n.t('Default')} </span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
|
||||
@@ -72,7 +114,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if options.temperature !== ''}
|
||||
{#if (params?.temperature ?? '') !== ''}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<input
|
||||
@@ -81,13 +123,13 @@
|
||||
min="0"
|
||||
max="1"
|
||||
step="0.05"
|
||||
bind:value={options.temperature}
|
||||
bind:value={params.temperature}
|
||||
class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
bind:value={options.temperature}
|
||||
bind:value={params.temperature}
|
||||
type="number"
|
||||
class=" bg-transparent text-center w-14"
|
||||
min="0"
|
||||
@@ -107,18 +149,18 @@
|
||||
class="p-1 px-3 text-xs flex rounded transition"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
options.mirostat = options.mirostat === '' ? 0 : '';
|
||||
params.mirostat = (params?.mirostat ?? '') === '' ? 0 : '';
|
||||
}}
|
||||
>
|
||||
{#if options.mirostat === ''}
|
||||
{#if (params?.mirostat ?? '') === ''}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if options.mirostat !== ''}
|
||||
{#if (params?.mirostat ?? '') !== ''}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<input
|
||||
@@ -127,13 +169,13 @@
|
||||
min="0"
|
||||
max="2"
|
||||
step="1"
|
||||
bind:value={options.mirostat}
|
||||
bind:value={params.mirostat}
|
||||
class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
bind:value={options.mirostat}
|
||||
bind:value={params.mirostat}
|
||||
type="number"
|
||||
class=" bg-transparent text-center w-14"
|
||||
min="0"
|
||||
@@ -153,18 +195,18 @@
|
||||
class="p-1 px-3 text-xs flex rounded transition"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
options.mirostat_eta = options.mirostat_eta === '' ? 0.1 : '';
|
||||
params.mirostat_eta = (params?.mirostat_eta ?? '') === '' ? 0.1 : '';
|
||||
}}
|
||||
>
|
||||
{#if options.mirostat_eta === ''}
|
||||
{#if (params?.mirostat_eta ?? '') === ''}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if options.mirostat_eta !== ''}
|
||||
{#if (params?.mirostat_eta ?? '') !== ''}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<input
|
||||
@@ -173,13 +215,13 @@
|
||||
min="0"
|
||||
max="1"
|
||||
step="0.05"
|
||||
bind:value={options.mirostat_eta}
|
||||
bind:value={params.mirostat_eta}
|
||||
class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
bind:value={options.mirostat_eta}
|
||||
bind:value={params.mirostat_eta}
|
||||
type="number"
|
||||
class=" bg-transparent text-center w-14"
|
||||
min="0"
|
||||
@@ -199,10 +241,10 @@
|
||||
class="p-1 px-3 text-xs flex rounded transition"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
options.mirostat_tau = options.mirostat_tau === '' ? 5.0 : '';
|
||||
params.mirostat_tau = (params?.mirostat_tau ?? '') === '' ? 5.0 : '';
|
||||
}}
|
||||
>
|
||||
{#if options.mirostat_tau === ''}
|
||||
{#if (params?.mirostat_tau ?? '') === ''}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
||||
@@ -210,7 +252,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if options.mirostat_tau !== ''}
|
||||
{#if (params?.mirostat_tau ?? '') !== ''}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<input
|
||||
@@ -219,13 +261,13 @@
|
||||
min="0"
|
||||
max="10"
|
||||
step="0.5"
|
||||
bind:value={options.mirostat_tau}
|
||||
bind:value={params.mirostat_tau}
|
||||
class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
bind:value={options.mirostat_tau}
|
||||
bind:value={params.mirostat_tau}
|
||||
type="number"
|
||||
class=" bg-transparent text-center w-14"
|
||||
min="0"
|
||||
@@ -245,18 +287,18 @@
|
||||
class="p-1 px-3 text-xs flex rounded transition"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
options.top_k = options.top_k === '' ? 40 : '';
|
||||
params.top_k = (params?.top_k ?? '') === '' ? 40 : '';
|
||||
}}
|
||||
>
|
||||
{#if options.top_k === ''}
|
||||
{#if (params?.top_k ?? '') === ''}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if options.top_k !== ''}
|
||||
{#if (params?.top_k ?? '') !== ''}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<input
|
||||
@@ -265,13 +307,13 @@
|
||||
min="0"
|
||||
max="100"
|
||||
step="0.5"
|
||||
bind:value={options.top_k}
|
||||
bind:value={params.top_k}
|
||||
class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
bind:value={options.top_k}
|
||||
bind:value={params.top_k}
|
||||
type="number"
|
||||
class=" bg-transparent text-center w-14"
|
||||
min="0"
|
||||
@@ -291,18 +333,18 @@
|
||||
class="p-1 px-3 text-xs flex rounded transition"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
options.top_p = options.top_p === '' ? 0.9 : '';
|
||||
params.top_p = (params?.top_p ?? '') === '' ? 0.9 : '';
|
||||
}}
|
||||
>
|
||||
{#if options.top_p === ''}
|
||||
{#if (params?.top_p ?? '') === ''}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if options.top_p !== ''}
|
||||
{#if (params?.top_p ?? '') !== ''}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<input
|
||||
@@ -311,13 +353,13 @@
|
||||
min="0"
|
||||
max="1"
|
||||
step="0.05"
|
||||
bind:value={options.top_p}
|
||||
bind:value={params.top_p}
|
||||
class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
bind:value={options.top_p}
|
||||
bind:value={params.top_p}
|
||||
type="number"
|
||||
class=" bg-transparent text-center w-14"
|
||||
min="0"
|
||||
@@ -337,18 +379,18 @@
|
||||
class="p-1 px-3 text-xs flex rounded transition"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
options.repeat_penalty = options.repeat_penalty === '' ? 1.1 : '';
|
||||
params.repeat_penalty = (params?.repeat_penalty ?? '') === '' ? 1.1 : '';
|
||||
}}
|
||||
>
|
||||
{#if options.repeat_penalty === ''}
|
||||
{#if (params?.repeat_penalty ?? '') === ''}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if options.repeat_penalty !== ''}
|
||||
{#if (params?.repeat_penalty ?? '') !== ''}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<input
|
||||
@@ -357,13 +399,13 @@
|
||||
min="0"
|
||||
max="2"
|
||||
step="0.05"
|
||||
bind:value={options.repeat_penalty}
|
||||
bind:value={params.repeat_penalty}
|
||||
class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
bind:value={options.repeat_penalty}
|
||||
bind:value={params.repeat_penalty}
|
||||
type="number"
|
||||
class=" bg-transparent text-center w-14"
|
||||
min="0"
|
||||
@@ -383,18 +425,18 @@
|
||||
class="p-1 px-3 text-xs flex rounded transition"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
options.repeat_last_n = options.repeat_last_n === '' ? 64 : '';
|
||||
params.repeat_last_n = (params?.repeat_last_n ?? '') === '' ? 64 : '';
|
||||
}}
|
||||
>
|
||||
{#if options.repeat_last_n === ''}
|
||||
{#if (params?.repeat_last_n ?? '') === ''}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if options.repeat_last_n !== ''}
|
||||
{#if (params?.repeat_last_n ?? '') !== ''}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<input
|
||||
@@ -403,13 +445,13 @@
|
||||
min="-1"
|
||||
max="128"
|
||||
step="1"
|
||||
bind:value={options.repeat_last_n}
|
||||
bind:value={params.repeat_last_n}
|
||||
class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
bind:value={options.repeat_last_n}
|
||||
bind:value={params.repeat_last_n}
|
||||
type="number"
|
||||
class=" bg-transparent text-center w-14"
|
||||
min="-1"
|
||||
@@ -429,18 +471,18 @@
|
||||
class="p-1 px-3 text-xs flex rounded transition"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
options.tfs_z = options.tfs_z === '' ? 1 : '';
|
||||
params.tfs_z = (params?.tfs_z ?? '') === '' ? 1 : '';
|
||||
}}
|
||||
>
|
||||
{#if options.tfs_z === ''}
|
||||
{#if (params?.tfs_z ?? '') === ''}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if options.tfs_z !== ''}
|
||||
{#if (params?.tfs_z ?? '') !== ''}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<input
|
||||
@@ -449,13 +491,13 @@
|
||||
min="0"
|
||||
max="2"
|
||||
step="0.05"
|
||||
bind:value={options.tfs_z}
|
||||
bind:value={params.tfs_z}
|
||||
class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
bind:value={options.tfs_z}
|
||||
bind:value={params.tfs_z}
|
||||
type="number"
|
||||
class=" bg-transparent text-center w-14"
|
||||
min="0"
|
||||
@@ -475,18 +517,18 @@
|
||||
class="p-1 px-3 text-xs flex rounded transition"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
options.num_ctx = options.num_ctx === '' ? 2048 : '';
|
||||
params.num_ctx = (params?.num_ctx ?? '') === '' ? 2048 : '';
|
||||
}}
|
||||
>
|
||||
{#if options.num_ctx === ''}
|
||||
{#if (params?.num_ctx ?? '') === ''}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if options.num_ctx !== ''}
|
||||
{#if (params?.num_ctx ?? '') !== ''}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<input
|
||||
@@ -495,13 +537,13 @@
|
||||
min="-1"
|
||||
max="10240000"
|
||||
step="1"
|
||||
bind:value={options.num_ctx}
|
||||
bind:value={params.num_ctx}
|
||||
class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
|
||||
/>
|
||||
</div>
|
||||
<div class="">
|
||||
<input
|
||||
bind:value={options.num_ctx}
|
||||
bind:value={params.num_ctx}
|
||||
type="number"
|
||||
class=" bg-transparent text-center w-14"
|
||||
min="-1"
|
||||
@@ -519,18 +561,18 @@
|
||||
class="p-1 px-3 text-xs flex rounded transition"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
options.num_predict = options.num_predict === '' ? 128 : '';
|
||||
params.num_predict = (params?.num_predict ?? '') === '' ? 128 : '';
|
||||
}}
|
||||
>
|
||||
{#if options.num_predict === ''}
|
||||
{#if (params?.num_predict ?? '') === ''}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if options.num_predict !== ''}
|
||||
{#if (params?.num_predict ?? '') !== ''}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<input
|
||||
@@ -539,13 +581,13 @@
|
||||
min="-2"
|
||||
max="16000"
|
||||
step="1"
|
||||
bind:value={options.num_predict}
|
||||
bind:value={params.num_predict}
|
||||
class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
|
||||
/>
|
||||
</div>
|
||||
<div class="">
|
||||
<input
|
||||
bind:value={options.num_predict}
|
||||
bind:value={params.num_predict}
|
||||
type="number"
|
||||
class=" bg-transparent text-center w-14"
|
||||
min="-2"
|
||||
@@ -556,4 +598,36 @@
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class=" py-0.5 w-full justify-between">
|
||||
<div class="flex w-full justify-between">
|
||||
<div class=" self-center text-xs font-medium">{$i18n.t('Template')}</div>
|
||||
|
||||
<button
|
||||
class="p-1 px-3 text-xs flex rounded transition"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
params.template = (params?.template ?? null) === null ? '' : null;
|
||||
}}
|
||||
>
|
||||
{#if (params?.template ?? null) === null}
|
||||
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if (params?.template ?? null) !== null}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<textarea
|
||||
class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg -mb-1"
|
||||
placeholder="Write your model template content here"
|
||||
rows="4"
|
||||
bind:value={params.template}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
let requestFormat = '';
|
||||
let keepAlive = null;
|
||||
|
||||
let options = {
|
||||
let params = {
|
||||
// Advanced
|
||||
seed: 0,
|
||||
temperature: '',
|
||||
@@ -80,14 +80,14 @@
|
||||
requestFormat = settings.requestFormat ?? '';
|
||||
keepAlive = settings.keepAlive ?? null;
|
||||
|
||||
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 };
|
||||
options.stop = (settings?.options?.stop ?? []).join(',');
|
||||
params.seed = settings.seed ?? 0;
|
||||
params.temperature = settings.temperature ?? '';
|
||||
params.repeat_penalty = settings.repeat_penalty ?? '';
|
||||
params.top_k = settings.top_k ?? '';
|
||||
params.top_p = settings.top_p ?? '';
|
||||
params.num_ctx = settings.num_ctx ?? '';
|
||||
params = { ...params, ...settings.params };
|
||||
params.stop = (settings?.params?.stop ?? []).join(',');
|
||||
});
|
||||
|
||||
const applyTheme = (_theme: string) => {
|
||||
@@ -228,7 +228,7 @@
|
||||
</div>
|
||||
|
||||
{#if showAdvanced}
|
||||
<AdvancedParams bind:options />
|
||||
<AdvancedParams bind:params />
|
||||
<hr class=" dark:border-gray-700" />
|
||||
|
||||
<div class=" py-1 w-full justify-between">
|
||||
@@ -300,20 +300,20 @@
|
||||
on:click={() => {
|
||||
saveSettings({
|
||||
system: system !== '' ? system : undefined,
|
||||
options: {
|
||||
seed: (options.seed !== 0 ? options.seed : undefined) ?? undefined,
|
||||
stop: options.stop !== '' ? options.stop.split(',').filter((e) => e) : undefined,
|
||||
temperature: options.temperature !== '' ? options.temperature : undefined,
|
||||
repeat_penalty: options.repeat_penalty !== '' ? options.repeat_penalty : undefined,
|
||||
repeat_last_n: options.repeat_last_n !== '' ? options.repeat_last_n : undefined,
|
||||
mirostat: options.mirostat !== '' ? options.mirostat : undefined,
|
||||
mirostat_eta: options.mirostat_eta !== '' ? options.mirostat_eta : undefined,
|
||||
mirostat_tau: options.mirostat_tau !== '' ? options.mirostat_tau : undefined,
|
||||
top_k: options.top_k !== '' ? options.top_k : undefined,
|
||||
top_p: options.top_p !== '' ? options.top_p : undefined,
|
||||
tfs_z: options.tfs_z !== '' ? options.tfs_z : undefined,
|
||||
num_ctx: options.num_ctx !== '' ? options.num_ctx : undefined,
|
||||
num_predict: options.num_predict !== '' ? options.num_predict : undefined
|
||||
params: {
|
||||
seed: (params.seed !== 0 ? params.seed : undefined) ?? undefined,
|
||||
stop: params.stop !== '' ? params.stop.split(',').filter((e) => e) : undefined,
|
||||
temperature: params.temperature !== '' ? params.temperature : undefined,
|
||||
repeat_penalty: params.repeat_penalty !== '' ? params.repeat_penalty : undefined,
|
||||
repeat_last_n: params.repeat_last_n !== '' ? params.repeat_last_n : undefined,
|
||||
mirostat: params.mirostat !== '' ? params.mirostat : undefined,
|
||||
mirostat_eta: params.mirostat_eta !== '' ? params.mirostat_eta : undefined,
|
||||
mirostat_tau: params.mirostat_tau !== '' ? params.mirostat_tau : undefined,
|
||||
top_k: params.top_k !== '' ? params.top_k : undefined,
|
||||
top_p: params.top_p !== '' ? params.top_p : undefined,
|
||||
tfs_z: params.tfs_z !== '' ? params.tfs_z : undefined,
|
||||
num_ctx: params.num_ctx !== '' ? params.num_ctx : undefined,
|
||||
num_predict: params.num_predict !== '' ? params.num_predict : undefined
|
||||
},
|
||||
keepAlive: keepAlive ? (isNaN(keepAlive) ? keepAlive : parseInt(keepAlive)) : undefined
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user