mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-05 19:17:56 -05:00
1713 lines
55 KiB
Svelte
1713 lines
55 KiB
Svelte
<script lang="ts">
|
|
import UserSettingRow from '../UserSettingRow.svelte';
|
|
import Switch from '$lib/components/common/Switch.svelte';
|
|
import Textarea from '$lib/components/common/Textarea.svelte';
|
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
|
import CustomParams from './CustomParams.svelte';
|
|
import type { i18n as i18nType } from 'i18next';
|
|
import { getContext } from 'svelte';
|
|
import type { Writable } from 'svelte/store';
|
|
|
|
const i18n = getContext<Writable<i18nType>>('i18n');
|
|
|
|
export let onChange: (params: any) => void = () => {};
|
|
export let onParamChange: (key: string, value: unknown) => void = () => {};
|
|
|
|
export let admin = false;
|
|
export let custom = false;
|
|
export let layout: 'stack' | 'grid' = 'stack';
|
|
|
|
const defaultParams = {
|
|
// Advanced
|
|
stream_response: null, // Set stream responses for this model individually
|
|
stream_delta_chunk_size: null, // Set the chunk size for streaming responses
|
|
compact_token_threshold: null,
|
|
function_calling: null,
|
|
reasoning_tags: null,
|
|
seed: null,
|
|
stop: null,
|
|
temperature: null,
|
|
reasoning_effort: null,
|
|
logit_bias: null,
|
|
max_tokens: null,
|
|
top_k: null,
|
|
top_p: null,
|
|
min_p: null,
|
|
frequency_penalty: null,
|
|
presence_penalty: null,
|
|
mirostat: null,
|
|
mirostat_eta: null,
|
|
mirostat_tau: null,
|
|
repeat_last_n: null,
|
|
tfs_z: null,
|
|
repeat_penalty: null,
|
|
use_mmap: null,
|
|
use_mlock: null,
|
|
think: null,
|
|
format: null,
|
|
keep_alive: null,
|
|
num_keep: null,
|
|
num_ctx: null,
|
|
num_batch: null,
|
|
num_thread: null,
|
|
num_gpu: null
|
|
};
|
|
type RangeParamKey = keyof typeof defaultParams;
|
|
|
|
export let params: any = defaultParams;
|
|
$: if (params) {
|
|
onChange(params);
|
|
}
|
|
|
|
const setTopK = (event: Event) => {
|
|
const input = event.currentTarget as HTMLInputElement;
|
|
const rawValue = input.value;
|
|
const value = Number(rawValue);
|
|
|
|
if (!/^\d+$/.test(rawValue) || value < 0 || value > 1000) {
|
|
input.value = `${params.top_k ?? ''}`;
|
|
return;
|
|
}
|
|
|
|
params.top_k = value;
|
|
};
|
|
</script>
|
|
|
|
{#snippet rangeParam(
|
|
key: RangeParamKey,
|
|
label: string,
|
|
min: number,
|
|
max: number,
|
|
rangeStep: number | string,
|
|
numberStep: number | string = 'any',
|
|
numberMax: number | undefined = max
|
|
)}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<div class=" flex-1">
|
|
<input
|
|
type="range"
|
|
aria-label={label}
|
|
{min}
|
|
{max}
|
|
step={rangeStep}
|
|
bind:value={params[key]}
|
|
on:change={() => onParamChange(key, params[key] ?? null)}
|
|
class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
|
|
/>
|
|
</div>
|
|
<div>
|
|
<input
|
|
bind:value={params[key]}
|
|
on:change={() => onParamChange(key, params[key] ?? null)}
|
|
type="number"
|
|
aria-label={label}
|
|
class=" bg-transparent text-center w-14"
|
|
{min}
|
|
max={numberMax}
|
|
step={numberStep}
|
|
/>
|
|
</div>
|
|
</div>
|
|
{/snippet}
|
|
|
|
<div
|
|
class={layout === 'grid'
|
|
? 'grid grid-cols-1 gap-x-5 gap-y-1 pb-safe-bottom text-xs text-gray-900 dark:text-gray-100 sm:grid-cols-2 lg:grid-cols-3'
|
|
: 'space-y-1 pb-safe-bottom text-xs text-gray-900 dark:text-gray-100'}
|
|
>
|
|
<div>
|
|
<Tooltip
|
|
content={$i18n.t('settings.personal.general.parameters.streamChatResponse.description')}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.streamChatResponse.label')}
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition font-normal text-gray-900 dark:text-gray-100"
|
|
on:click={() => {
|
|
params.stream_response =
|
|
(params?.stream_response ?? null) === null
|
|
? true
|
|
: params.stream_response
|
|
? false
|
|
: null;
|
|
onParamChange('stream_response', params.stream_response);
|
|
}}
|
|
type="button"
|
|
>
|
|
{#if params.stream_response === true}
|
|
<span class="ml-2 self-center">{$i18n.t('On')}</span>
|
|
{:else if params.stream_response === false}
|
|
<span class="ml-2 self-center">{$i18n.t('Off')}</span>
|
|
{:else}
|
|
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
|
{/if}
|
|
</button>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
</div>
|
|
|
|
{#if admin}
|
|
<div>
|
|
<Tooltip
|
|
content={$i18n.t('settings.personal.general.parameters.streamDeltaChunkSize.description')}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.streamDeltaChunkSize.label')}
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.stream_delta_chunk_size =
|
|
(params?.stream_delta_chunk_size ?? null) === null ? 1 : null;
|
|
onParamChange('stream_delta_chunk_size', params.stream_delta_chunk_size);
|
|
}}
|
|
>
|
|
{#if (params?.stream_delta_chunk_size ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.stream_delta_chunk_size ?? null) !== null}
|
|
{@render rangeParam(
|
|
'stream_delta_chunk_size',
|
|
$i18n.t('settings.personal.general.parameters.streamDeltaChunkSize.label'),
|
|
1,
|
|
128,
|
|
1,
|
|
'any',
|
|
undefined
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div>
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'settings.personal.general.parameters.contextCompactionThreshold.description'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.contextCompactionThreshold.label')}
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.compact_token_threshold =
|
|
(params?.compact_token_threshold ?? null) === null ? 80000 : null;
|
|
onParamChange('compact_token_threshold', params.compact_token_threshold);
|
|
}}
|
|
>
|
|
{#if (params?.compact_token_threshold ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.compact_token_threshold ?? null) !== null}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<div class=" flex-1">
|
|
<input
|
|
class="text-sm w-full bg-transparent outline-hidden outline-none font-normal text-gray-900 dark:text-gray-100"
|
|
type="number"
|
|
aria-label={$i18n.t(
|
|
'settings.personal.general.parameters.contextCompactionThreshold.label'
|
|
)}
|
|
placeholder={$i18n.t('Enter token threshold')}
|
|
bind:value={params.compact_token_threshold}
|
|
on:change={() =>
|
|
onParamChange('compact_token_threshold', params.compact_token_threshold ?? null)}
|
|
autocomplete="off"
|
|
min="1"
|
|
step="1"
|
|
/>
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
{/if}
|
|
|
|
<div>
|
|
<Tooltip
|
|
content={$i18n.t('settings.personal.general.parameters.functionCalling.description')}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.functionCalling.label')}
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition font-normal text-gray-900 dark:text-gray-100"
|
|
on:click={() => {
|
|
if ((params?.function_calling ?? null) === null) {
|
|
params.function_calling = 'native';
|
|
} else if (params.function_calling === 'native') {
|
|
params.function_calling = 'legacy';
|
|
} else {
|
|
params.function_calling = null;
|
|
}
|
|
onParamChange('function_calling', params.function_calling);
|
|
}}
|
|
type="button"
|
|
>
|
|
{#if params.function_calling === 'native'}
|
|
<span class="ml-2 self-center">{$i18n.t('Native')}</span>
|
|
{:else if params.function_calling === 'legacy'}
|
|
<span class="ml-2 self-center">{$i18n.t('Legacy')}</span>
|
|
{:else}
|
|
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
|
{/if}
|
|
</button>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t('settings.personal.general.parameters.reasoningTags.description')}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.reasoningTags.label')}
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
if ((params?.reasoning_tags ?? null) === null) {
|
|
params.reasoning_tags = ['', ''];
|
|
} else if ((params?.reasoning_tags ?? []).length === 2) {
|
|
params.reasoning_tags = true;
|
|
} else if ((params?.reasoning_tags ?? null) !== false) {
|
|
params.reasoning_tags = false;
|
|
} else {
|
|
params.reasoning_tags = null;
|
|
}
|
|
onParamChange('reasoning_tags', params.reasoning_tags);
|
|
}}
|
|
>
|
|
{#if (params?.reasoning_tags ?? null) === null}
|
|
<span class="ml-2 self-center"> {$i18n.t('Default')} </span>
|
|
{:else if (params?.reasoning_tags ?? null) === true}
|
|
<span class="ml-2 self-center"> {$i18n.t('Enabled')} </span>
|
|
{:else if (params?.reasoning_tags ?? null) === false}
|
|
<span class="ml-2 self-center"> {$i18n.t('Disabled')} </span>
|
|
{:else}
|
|
<span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
|
|
{/if}
|
|
</button>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if ![true, false, null].includes(params?.reasoning_tags ?? null) && (params?.reasoning_tags ?? []).length === 2}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<div class=" flex-1">
|
|
<input
|
|
class="text-sm w-full bg-transparent outline-hidden outline-none font-normal text-gray-900 dark:text-gray-100"
|
|
type="text"
|
|
aria-label={$i18n.t('Start Tag')}
|
|
placeholder={$i18n.t('Start Tag')}
|
|
bind:value={params.reasoning_tags[0]}
|
|
on:change={() => onParamChange('reasoning_tags', params.reasoning_tags ?? null)}
|
|
autocomplete="off"
|
|
/>
|
|
</div>
|
|
|
|
<div class=" flex-1">
|
|
<input
|
|
class="text-sm w-full bg-transparent outline-hidden outline-none font-normal text-gray-900 dark:text-gray-100"
|
|
type="text"
|
|
aria-label={$i18n.t('End Tag')}
|
|
placeholder={$i18n.t('End Tag')}
|
|
bind:value={params.reasoning_tags[1]}
|
|
on:change={() => onParamChange('reasoning_tags', params.reasoning_tags ?? null)}
|
|
autocomplete="off"
|
|
/>
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t('settings.personal.general.parameters.seed.description')}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.seed.label')}
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.seed = (params?.seed ?? null) === null ? 0 : null;
|
|
onParamChange('seed', params.seed);
|
|
}}
|
|
>
|
|
{#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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.seed ?? null) !== null}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<div class=" flex-1">
|
|
<input
|
|
class="text-sm w-full bg-transparent outline-hidden outline-none font-normal text-gray-900 dark:text-gray-100"
|
|
type="number"
|
|
aria-label={$i18n.t('settings.personal.general.parameters.seed.label')}
|
|
placeholder={$i18n.t('Enter Seed')}
|
|
bind:value={params.seed}
|
|
on:change={() => onParamChange('seed', params.seed ?? null)}
|
|
autocomplete="off"
|
|
min="0"
|
|
/>
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t('settings.personal.general.parameters.stopSequence.description')}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.stopSequence.label')}
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.stop = (params?.stop ?? null) === null ? '' : null;
|
|
onParamChange('stop', params.stop);
|
|
}}
|
|
>
|
|
{#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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.stop ?? null) !== null}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<div class=" flex-1">
|
|
<input
|
|
class="text-sm w-full bg-transparent outline-hidden outline-none font-normal text-gray-900 dark:text-gray-100"
|
|
type="text"
|
|
aria-label={$i18n.t('settings.personal.general.parameters.stopSequence.label')}
|
|
placeholder={$i18n.t('Enter stop sequence')}
|
|
bind:value={params.stop}
|
|
on:change={() => onParamChange('stop', params.stop ?? null)}
|
|
autocomplete="off"
|
|
/>
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t('settings.personal.general.parameters.temperature.description')}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.temperature.label')}
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.temperature = (params?.temperature ?? null) === null ? 0.8 : null;
|
|
onParamChange('temperature', params.temperature);
|
|
}}
|
|
>
|
|
{#if (params?.temperature ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.temperature ?? null) !== null}
|
|
{@render rangeParam(
|
|
'temperature',
|
|
$i18n.t('settings.personal.general.parameters.temperature.label'),
|
|
0,
|
|
2,
|
|
0.05
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t('settings.personal.general.parameters.reasoningEffort.description')}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.reasoningEffort.label')}
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.reasoning_effort = (params?.reasoning_effort ?? null) === null ? 'medium' : null;
|
|
onParamChange('reasoning_effort', params.reasoning_effort);
|
|
}}
|
|
>
|
|
{#if (params?.reasoning_effort ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.reasoning_effort ?? null) !== null}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<div class=" flex-1">
|
|
<input
|
|
class="text-sm w-full bg-transparent outline-hidden outline-none font-normal text-gray-900 dark:text-gray-100"
|
|
type="text"
|
|
aria-label={$i18n.t('settings.personal.general.parameters.reasoningEffort.label')}
|
|
placeholder={$i18n.t('Enter reasoning effort')}
|
|
bind:value={params.reasoning_effort}
|
|
on:change={() => onParamChange('reasoning_effort', params.reasoning_effort ?? null)}
|
|
autocomplete="off"
|
|
/>
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'Boosting or penalizing specific tokens for constrained responses. Bias values will be clamped between -100 and 100 (inclusive). (Default: none)'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.logitBias.label')}
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.logit_bias = (params?.logit_bias ?? null) === null ? '' : null;
|
|
onParamChange('logit_bias', params.logit_bias);
|
|
}}
|
|
>
|
|
{#if (params?.logit_bias ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.logit_bias ?? null) !== null}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<div class=" flex-1">
|
|
<input
|
|
class="text-sm w-full bg-transparent outline-hidden outline-none font-normal text-gray-900 dark:text-gray-100"
|
|
type="text"
|
|
aria-label={$i18n.t('settings.personal.general.parameters.logitBias.label')}
|
|
placeholder={$i18n.t(
|
|
'Enter comma-separated "token:bias_value" pairs (example: 5432:100, 413:-100)'
|
|
)}
|
|
bind:value={params.logit_bias}
|
|
on:change={() => onParamChange('logit_bias', params.logit_bias ?? null)}
|
|
autocomplete="off"
|
|
/>
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'This option sets the maximum number of tokens the model can generate in its response. Increasing this limit allows the model to provide longer answers, but it may also increase the likelihood of unhelpful or irrelevant content being generated.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.maxTokens.label')}
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.max_tokens = (params?.max_tokens ?? null) === null ? 128 : null;
|
|
onParamChange('max_tokens', params.max_tokens);
|
|
}}
|
|
>
|
|
{#if (params?.max_tokens ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.max_tokens ?? null) !== null}
|
|
{@render rangeParam(
|
|
'max_tokens',
|
|
$i18n.t('settings.personal.general.parameters.maxTokens.label'),
|
|
-2,
|
|
131072,
|
|
1,
|
|
1,
|
|
undefined
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'Reduces the probability of generating nonsense. A higher value (e.g. 100) will give more diverse answers, while a lower value (e.g. 10) will be more conservative.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.topK.label')}
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.top_k = (params?.top_k ?? null) === null ? 40 : null;
|
|
onParamChange('top_k', params.top_k);
|
|
}}
|
|
>
|
|
{#if (params?.top_k ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.top_k ?? null) !== null}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<div class=" flex-1">
|
|
<input
|
|
type="range"
|
|
aria-label={$i18n.t('settings.personal.general.parameters.topK.label')}
|
|
min="0"
|
|
max="1000"
|
|
step="1"
|
|
value={params.top_k}
|
|
on:input={setTopK}
|
|
on:change={() => onParamChange('top_k', params.top_k ?? null)}
|
|
class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-gray-700"
|
|
/>
|
|
</div>
|
|
<div>
|
|
<input
|
|
value={params.top_k}
|
|
type="number"
|
|
aria-label={$i18n.t('settings.personal.general.parameters.topK.label')}
|
|
class=" bg-transparent text-center w-14"
|
|
min="0"
|
|
max="1000"
|
|
step="1"
|
|
on:input={setTopK}
|
|
on:change={() => onParamChange('top_k', params.top_k ?? null)}
|
|
/>
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'Works together with top-k. A higher value (e.g., 0.95) will lead to more diverse text, while a lower value (e.g., 0.5) will generate more focused and conservative text.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.topP.label')}
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.top_p = (params?.top_p ?? null) === null ? 0.9 : null;
|
|
onParamChange('top_p', params.top_p);
|
|
}}
|
|
>
|
|
{#if (params?.top_p ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.top_p ?? null) !== null}
|
|
{@render rangeParam(
|
|
'top_p',
|
|
$i18n.t('settings.personal.general.parameters.topP.label'),
|
|
0,
|
|
1,
|
|
0.05
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'Alternative to the top_p, and aims to ensure a balance of quality and variety. The parameter p represents the minimum probability for a token to be considered, relative to the probability of the most likely token. For example, with p=0.05 and the most likely token having a probability of 0.9, logits with a value less than 0.045 are filtered out.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.minP.label')}
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.min_p = (params?.min_p ?? null) === null ? 0.0 : null;
|
|
onParamChange('min_p', params.min_p);
|
|
}}
|
|
>
|
|
{#if (params?.min_p ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.min_p ?? null) !== null}
|
|
{@render rangeParam(
|
|
'min_p',
|
|
$i18n.t('settings.personal.general.parameters.minP.label'),
|
|
0,
|
|
1,
|
|
0.05
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'Sets a scaling bias against tokens to penalize repetitions, based on how many times they have appeared. A higher value (e.g., 1.5) will penalize repetitions more strongly, while a lower value (e.g., 0.9) will be more lenient. At 0, it is disabled.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.frequencyPenalty.label')}
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.frequency_penalty = (params?.frequency_penalty ?? null) === null ? 1.1 : null;
|
|
onParamChange('frequency_penalty', params.frequency_penalty);
|
|
}}
|
|
>
|
|
{#if (params?.frequency_penalty ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.frequency_penalty ?? null) !== null}
|
|
{@render rangeParam(
|
|
'frequency_penalty',
|
|
$i18n.t('settings.personal.general.parameters.frequencyPenalty.label'),
|
|
-2,
|
|
2,
|
|
0.05
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'Sets a flat bias against tokens that have appeared at least once. A higher value (e.g., 1.5) will penalize repetitions more strongly, while a lower value (e.g., 0.9) will be more lenient. At 0, it is disabled.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.presencePenalty.label')}
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.presence_penalty = (params?.presence_penalty ?? null) === null ? 0.0 : null;
|
|
onParamChange('presence_penalty', params.presence_penalty);
|
|
}}
|
|
>
|
|
{#if (params?.presence_penalty ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.presence_penalty ?? null) !== null}
|
|
{@render rangeParam(
|
|
'presence_penalty',
|
|
$i18n.t('settings.personal.general.parameters.presencePenalty.label'),
|
|
-2,
|
|
2,
|
|
0.05
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t('Enable Mirostat sampling for controlling perplexity.')}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.mirostat.label')}
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.mirostat = (params?.mirostat ?? null) === null ? 0 : null;
|
|
onParamChange('mirostat', params.mirostat);
|
|
}}
|
|
>
|
|
{#if (params?.mirostat ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.mirostat ?? null) !== null}
|
|
{@render rangeParam(
|
|
'mirostat',
|
|
$i18n.t('settings.personal.general.parameters.mirostat.label'),
|
|
0,
|
|
2,
|
|
1,
|
|
1
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'Influences how quickly the algorithm responds to feedback from the generated text. A lower learning rate will result in slower adjustments, while a higher learning rate will make the algorithm more responsive.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.mirostatEta.label')}
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.mirostat_eta = (params?.mirostat_eta ?? null) === null ? 0.1 : null;
|
|
onParamChange('mirostat_eta', params.mirostat_eta);
|
|
}}
|
|
>
|
|
{#if (params?.mirostat_eta ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.mirostat_eta ?? null) !== null}
|
|
{@render rangeParam(
|
|
'mirostat_eta',
|
|
$i18n.t('settings.personal.general.parameters.mirostatEta.label'),
|
|
0,
|
|
1,
|
|
0.05
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'Controls the balance between coherence and diversity of the output. A lower value will result in more focused and coherent text.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.mirostatTau.label')}
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.mirostat_tau = (params?.mirostat_tau ?? null) === null ? 5.0 : null;
|
|
onParamChange('mirostat_tau', params.mirostat_tau);
|
|
}}
|
|
>
|
|
{#if (params?.mirostat_tau ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.mirostat_tau ?? null) !== null}
|
|
{@render rangeParam(
|
|
'mirostat_tau',
|
|
$i18n.t('settings.personal.general.parameters.mirostatTau.label'),
|
|
0,
|
|
10,
|
|
0.5
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t('Sets how far back for the model to look back to prevent repetition.')}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.repeatLastN.label')}
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.repeat_last_n = (params?.repeat_last_n ?? null) === null ? 64 : null;
|
|
onParamChange('repeat_last_n', params.repeat_last_n);
|
|
}}
|
|
>
|
|
{#if (params?.repeat_last_n ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.repeat_last_n ?? null) !== null}
|
|
{@render rangeParam(
|
|
'repeat_last_n',
|
|
$i18n.t('settings.personal.general.parameters.repeatLastN.label'),
|
|
-1,
|
|
128,
|
|
1,
|
|
1
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'Tail free sampling is used to reduce the impact of less probable tokens from the output. A higher value (e.g., 2.0) will reduce the impact more, while a value of 1.0 disables this setting.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.tfsZ.label')}
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.tfs_z = (params?.tfs_z ?? null) === null ? 1 : null;
|
|
onParamChange('tfs_z', params.tfs_z);
|
|
}}
|
|
>
|
|
{#if (params?.tfs_z ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.tfs_z ?? null) !== null}
|
|
{@render rangeParam(
|
|
'tfs_z',
|
|
$i18n.t('settings.personal.general.parameters.tfsZ.label'),
|
|
0,
|
|
2,
|
|
0.05
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'Control the repetition of token sequences in the generated text. A higher value (e.g., 1.5) will penalize repetitions more strongly, while a lower value (e.g., 1.1) will be more lenient. At 1, it is disabled.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.repeatPenalty.label')}
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded transition flex-shrink-0 outline-none font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.repeat_penalty = (params?.repeat_penalty ?? null) === null ? 1.1 : null;
|
|
onParamChange('repeat_penalty', params.repeat_penalty);
|
|
}}
|
|
>
|
|
{#if (params?.repeat_penalty ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.repeat_penalty ?? null) !== null}
|
|
{@render rangeParam(
|
|
'repeat_penalty',
|
|
$i18n.t('settings.personal.general.parameters.repeatPenalty.label'),
|
|
-2,
|
|
2,
|
|
0.05
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
{#if admin}
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'Enable Memory Mapping (mmap) to load model data. This option allows the system to use disk storage as an extension of RAM by treating disk files as if they were in RAM. This can improve model performance by allowing for faster data access. However, it may not work correctly with all systems and can consume a significant amount of disk space.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.useMmap.label')}
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.use_mmap = (params?.use_mmap ?? null) === null ? true : null;
|
|
onParamChange('use_mmap', params.use_mmap);
|
|
}}
|
|
>
|
|
{#if (params?.use_mmap ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.use_mmap ?? null) !== null}
|
|
<UserSettingRow let:labelId className="mt-1">
|
|
<span slot="label">
|
|
{params.use_mmap ? $i18n.t('Enabled') : $i18n.t('Disabled')}
|
|
</span>
|
|
<div class=" pr-2">
|
|
<Switch
|
|
ariaLabelledbyId={labelId}
|
|
bind:state={params.use_mmap}
|
|
on:change={(event) => onParamChange('use_mmap', event.detail)}
|
|
ariaLabel={$i18n.t('settings.personal.general.parameters.useMmap.label')}
|
|
/>
|
|
</div></UserSettingRow
|
|
>
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
"Enable Memory Locking (mlock) to prevent model data from being swapped out of RAM. This option locks the model's working set of pages into RAM, ensuring that they will not be swapped out to disk. This can help maintain performance by avoiding page faults and ensuring fast data access."
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.useMlock.label')}
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.use_mlock = (params?.use_mlock ?? null) === null ? true : null;
|
|
onParamChange('use_mlock', params.use_mlock);
|
|
}}
|
|
>
|
|
{#if (params?.use_mlock ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.use_mlock ?? null) !== null}
|
|
<UserSettingRow let:labelId className="mt-1">
|
|
<span slot="label">
|
|
{params.use_mlock ? $i18n.t('Enabled') : $i18n.t('Disabled')}
|
|
</span>
|
|
|
|
<div class=" pr-2">
|
|
<Switch
|
|
ariaLabelledbyId={labelId}
|
|
bind:state={params.use_mlock}
|
|
on:change={(event) => onParamChange('use_mlock', event.detail)}
|
|
ariaLabel={$i18n.t('settings.personal.general.parameters.useMlock.label')}
|
|
/>
|
|
</div></UserSettingRow
|
|
>
|
|
{/if}
|
|
</div>
|
|
{/if}
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t('settings.personal.general.parameters.ollama.description')}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.think.label')} ({$i18n.t(
|
|
'settings.personal.general.parameters.ollama.label'
|
|
)})
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition font-normal text-gray-900 dark:text-gray-100"
|
|
on:click={() => {
|
|
if ((params?.think ?? null) === null) {
|
|
params.think = true;
|
|
} else if (params.think === true) {
|
|
params.think = 'medium';
|
|
} else if (typeof params.think === 'string') {
|
|
params.think = false;
|
|
} else {
|
|
params.think = null;
|
|
}
|
|
onParamChange('think', params.think);
|
|
}}
|
|
type="button"
|
|
>
|
|
{#if params.think === true}
|
|
<span class="ml-2 self-center">{$i18n.t('On')}</span>
|
|
{:else if params.think === false}
|
|
<span class="ml-2 self-center">{$i18n.t('Off')}</span>
|
|
{:else if typeof params.think === 'string'}
|
|
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
|
{:else}
|
|
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
|
{/if}
|
|
</button>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if typeof params.think === 'string'}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<div class=" flex-1">
|
|
<input
|
|
class="text-sm w-full bg-transparent outline-hidden outline-none font-normal text-gray-900 dark:text-gray-100"
|
|
type="text"
|
|
aria-label={`${$i18n.t('settings.personal.general.parameters.think.label')} (${$i18n.t('settings.personal.general.parameters.ollama.label')})`}
|
|
placeholder={$i18n.t("e.g. 'low', 'medium', 'high'")}
|
|
bind:value={params.think}
|
|
on:change={() => onParamChange('think', params.think ?? null)}
|
|
autocomplete="off"
|
|
/>
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t('The format to return a response in. Format can be json or a JSON schema.')}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.format.label')} ({$i18n.t(
|
|
'settings.personal.general.parameters.ollama.label'
|
|
)})
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition font-normal text-gray-900 dark:text-gray-100"
|
|
on:click={() => {
|
|
params.format = (params?.format ?? null) === null ? 'json' : null;
|
|
onParamChange('format', params.format);
|
|
}}
|
|
type="button"
|
|
>
|
|
{#if (params?.format ?? null) === null}
|
|
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
|
{:else}
|
|
<span class="ml-2 self-center">{$i18n.t('JSON')}</span>
|
|
{/if}
|
|
</button>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.format ?? null) !== null}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<Textarea
|
|
className="w-full text-sm bg-transparent outline-hidden"
|
|
ariaLabel={`${$i18n.t('settings.personal.general.parameters.format.label')} (${$i18n.t('settings.personal.general.parameters.ollama.label')})`}
|
|
placeholder={$i18n.t('e.g. "json" or a JSON schema')}
|
|
bind:value={params.format}
|
|
on:change={() => onParamChange('format', params.format ?? null)}
|
|
/>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'This option controls how many tokens are preserved when refreshing the context. For example, if set to 2, the last 2 tokens of the conversation context will be retained. Preserving context can help maintain the continuity of a conversation, but it may reduce the ability to respond to new topics.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.numKeep.label')} ({$i18n.t(
|
|
'settings.personal.general.parameters.ollama.label'
|
|
)})
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.num_keep = (params?.num_keep ?? null) === null ? 24 : null;
|
|
onParamChange('num_keep', params.num_keep);
|
|
}}
|
|
>
|
|
{#if (params?.num_keep ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.num_keep ?? null) !== null}
|
|
{@render rangeParam(
|
|
'num_keep',
|
|
`${$i18n.t('settings.personal.general.parameters.numKeep.label')} (${$i18n.t('settings.personal.general.parameters.ollama.label')})`,
|
|
-1,
|
|
10240000,
|
|
1,
|
|
1,
|
|
undefined
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t('Sets the size of the context window used to generate the next token.')}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.numCtx.label')} ({$i18n.t(
|
|
'settings.personal.general.parameters.ollama.label'
|
|
)})
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.num_ctx = (params?.num_ctx ?? null) === null ? 2048 : null;
|
|
onParamChange('num_ctx', params.num_ctx);
|
|
}}
|
|
>
|
|
{#if (params?.num_ctx ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.num_ctx ?? null) !== null}
|
|
{@render rangeParam(
|
|
'num_ctx',
|
|
`${$i18n.t('settings.personal.general.parameters.numCtx.label')} (${$i18n.t('settings.personal.general.parameters.ollama.label')})`,
|
|
-1,
|
|
10240000,
|
|
1,
|
|
1,
|
|
undefined
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'The batch size determines how many text requests are processed together at once. A higher batch size can increase the performance and speed of the model, but it also requires more memory.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.numBatch.label')} ({$i18n.t(
|
|
'settings.personal.general.parameters.ollama.label'
|
|
)})
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.num_batch = (params?.num_batch ?? null) === null ? 512 : null;
|
|
onParamChange('num_batch', params.num_batch);
|
|
}}
|
|
>
|
|
{#if (params?.num_batch ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.num_batch ?? null) !== null}
|
|
{@render rangeParam(
|
|
'num_batch',
|
|
`${$i18n.t('settings.personal.general.parameters.numBatch.label')} (${$i18n.t('settings.personal.general.parameters.ollama.label')})`,
|
|
256,
|
|
8192,
|
|
256,
|
|
256,
|
|
undefined
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
{#if admin}
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'Set the number of worker threads used for computation. This option controls how many threads are used to process incoming requests concurrently. Increasing this value can improve performance under high concurrency workloads but may also consume more CPU resources.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.numThread.label')} ({$i18n.t(
|
|
'settings.personal.general.parameters.ollama.label'
|
|
)})
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.num_thread = (params?.num_thread ?? null) === null ? 2 : null;
|
|
onParamChange('num_thread', params.num_thread);
|
|
}}
|
|
>
|
|
{#if (params?.num_thread ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.num_thread ?? null) !== null}
|
|
{@render rangeParam(
|
|
'num_thread',
|
|
`${$i18n.t('settings.personal.general.parameters.numThread.label')} (${$i18n.t('settings.personal.general.parameters.ollama.label')})`,
|
|
1,
|
|
256,
|
|
1,
|
|
1
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'Set the number of layers, which will be off-loaded to GPU. Increasing this value can significantly improve performance for models that are optimized for GPU acceleration but may also consume more power and GPU resources.'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.numGpu.label')} ({$i18n.t(
|
|
'settings.personal.general.parameters.ollama.label'
|
|
)})
|
|
</span>
|
|
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="button"
|
|
on:click={() => {
|
|
params.num_gpu = (params?.num_gpu ?? null) === null ? 0 : null;
|
|
onParamChange('num_gpu', params.num_gpu);
|
|
}}
|
|
>
|
|
{#if (params?.num_gpu ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.num_gpu ?? null) !== null}
|
|
{@render rangeParam(
|
|
'num_gpu',
|
|
`${$i18n.t('settings.personal.general.parameters.numGpu.label')} (${$i18n.t('settings.personal.general.parameters.ollama.label')})`,
|
|
0,
|
|
256,
|
|
1,
|
|
1
|
|
)}
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" py-0.5 w-full justify-between">
|
|
<Tooltip
|
|
content={$i18n.t(
|
|
'This option controls how long the model will stay loaded into memory following the request (default: 5m)'
|
|
)}
|
|
placement="top-start"
|
|
className="inline-tooltip"
|
|
>
|
|
<UserSettingRow
|
|
let:labelId
|
|
className="w-full py-0.5"
|
|
labelClassName="self-center font-normal underline decoration-dotted decoration-gray-400/70 underline-offset-4 dark:decoration-gray-500"
|
|
>
|
|
<span slot="label">
|
|
{$i18n.t('settings.personal.general.parameters.keepAlive.label')} ({$i18n.t(
|
|
'settings.personal.general.parameters.ollama.label'
|
|
)})
|
|
</span>
|
|
<button
|
|
id={`${labelId}-control`}
|
|
class="p-1 px-3 text-xs flex rounded-sm transition font-normal text-gray-900 dark:text-gray-100"
|
|
on:click={() => {
|
|
params.keep_alive = (params?.keep_alive ?? null) === null ? '5m' : null;
|
|
onParamChange('keep_alive', params.keep_alive);
|
|
}}
|
|
type="button"
|
|
>
|
|
{#if (params?.keep_alive ?? 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>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
|
|
{#if (params?.keep_alive ?? null) !== null}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<input
|
|
class="w-full text-sm bg-transparent outline-hidden font-normal text-gray-900 dark:text-gray-100"
|
|
type="text"
|
|
aria-label={`${$i18n.t('settings.personal.general.parameters.keepAlive.label')} (${$i18n.t('settings.personal.general.parameters.ollama.label')})`}
|
|
placeholder={$i18n.t("e.g. '30s','10m'. Valid time units are 's', 'm', 'h'.")}
|
|
bind:value={params.keep_alive}
|
|
on:change={() => onParamChange('keep_alive', params.keep_alive ?? null)}
|
|
/>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
{#if custom && admin}
|
|
<CustomParams
|
|
bind:value={params.custom_params}
|
|
onChange={(value) => onParamChange('custom_params', value)}
|
|
/>
|
|
{/if}
|
|
{/if}
|
|
</div>
|