mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-05 11:07:55 -05:00
861 lines
28 KiB
Svelte
861 lines
28 KiB
Svelte
<script lang="ts">
|
|
import UserSettingRow from '../UserSettingRow.svelte';
|
|
import Switch from '$lib/components/common/Switch.svelte';
|
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
|
import XMark from '$lib/components/icons/XMark.svelte';
|
|
import Plus from '$lib/components/icons/Plus.svelte';
|
|
import TTSVoiceInput from '$lib/components/workspace/Models/TTSVoiceInput.svelte';
|
|
import type { i18n as i18nType } from 'i18next';
|
|
import { getContext } from 'svelte';
|
|
import type { Writable } from 'svelte/store';
|
|
import { config } from '$lib/stores';
|
|
|
|
const i18n = getContext<Writable<i18nType>>('i18n');
|
|
|
|
export let onChange: (params: any) => void = () => {};
|
|
export let onParamChange: (key: string, value: unknown) => void = () => {};
|
|
|
|
export let admin = false;
|
|
// Allows parameters outside the built-in list (saved to params.custom_params).
|
|
export let custom = false;
|
|
export let layout: 'stack' | 'grid' = 'stack';
|
|
|
|
export let params: any = {};
|
|
$: if (params) {
|
|
onChange(params);
|
|
}
|
|
|
|
type ModelParam = {
|
|
key: string;
|
|
label: string;
|
|
tip: string;
|
|
placeholder?: string;
|
|
kind: 'number' | 'bool' | 'text';
|
|
initial: unknown;
|
|
min?: number;
|
|
max?: number;
|
|
rangeStep?: number;
|
|
step?: number | 'any';
|
|
open?: boolean;
|
|
suggestions?: string[];
|
|
ollama?: boolean;
|
|
adminOnly?: boolean;
|
|
};
|
|
|
|
// Model parameters. Only the ones that are set are listed; the rest are offered by Add parameter.
|
|
let modelParams: ModelParam[] = [];
|
|
$: modelParams = [
|
|
{
|
|
key: 'temperature',
|
|
label: $i18n.t('settings.personal.general.parameters.temperature.label'),
|
|
tip: $i18n.t('settings.personal.general.parameters.temperature.description'),
|
|
kind: 'number',
|
|
initial: 0.8,
|
|
min: 0,
|
|
max: 2,
|
|
rangeStep: 0.05,
|
|
step: 'any'
|
|
},
|
|
{
|
|
key: 'max_tokens',
|
|
label: $i18n.t('settings.personal.general.parameters.maxTokens.label'),
|
|
tip: $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.'
|
|
),
|
|
kind: 'number',
|
|
initial: 128,
|
|
min: -2,
|
|
max: 131072,
|
|
rangeStep: 1,
|
|
step: 1,
|
|
open: true
|
|
},
|
|
{
|
|
key: 'top_k',
|
|
label: $i18n.t('settings.personal.general.parameters.topK.label'),
|
|
tip: $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.'
|
|
),
|
|
kind: 'number',
|
|
initial: 40,
|
|
min: 0,
|
|
max: 1000,
|
|
rangeStep: 1,
|
|
step: 1
|
|
},
|
|
{
|
|
key: 'top_p',
|
|
label: $i18n.t('settings.personal.general.parameters.topP.label'),
|
|
tip: $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.'
|
|
),
|
|
kind: 'number',
|
|
initial: 0.9,
|
|
min: 0,
|
|
max: 1,
|
|
rangeStep: 0.05,
|
|
step: 'any'
|
|
},
|
|
{
|
|
key: 'min_p',
|
|
label: $i18n.t('settings.personal.general.parameters.minP.label'),
|
|
tip: $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.'
|
|
),
|
|
kind: 'number',
|
|
initial: 0,
|
|
min: 0,
|
|
max: 1,
|
|
rangeStep: 0.05,
|
|
step: 'any'
|
|
},
|
|
{
|
|
key: 'frequency_penalty',
|
|
label: $i18n.t('settings.personal.general.parameters.frequencyPenalty.label'),
|
|
tip: $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.'
|
|
),
|
|
kind: 'number',
|
|
initial: 1.1,
|
|
min: -2,
|
|
max: 2,
|
|
rangeStep: 0.05,
|
|
step: 'any'
|
|
},
|
|
{
|
|
key: 'presence_penalty',
|
|
label: $i18n.t('settings.personal.general.parameters.presencePenalty.label'),
|
|
tip: $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.'
|
|
),
|
|
kind: 'number',
|
|
initial: 0,
|
|
min: -2,
|
|
max: 2,
|
|
rangeStep: 0.05,
|
|
step: 'any'
|
|
},
|
|
{
|
|
key: 'seed',
|
|
placeholder: $i18n.t('Enter Seed'),
|
|
label: $i18n.t('settings.personal.general.parameters.seed.label'),
|
|
tip: $i18n.t('settings.personal.general.parameters.seed.description'),
|
|
kind: 'number',
|
|
initial: 0,
|
|
step: 1,
|
|
open: true,
|
|
min: 0
|
|
},
|
|
{
|
|
key: 'stop',
|
|
placeholder: $i18n.t('Enter stop sequence'),
|
|
label: $i18n.t('settings.personal.general.parameters.stopSequence.label'),
|
|
tip: $i18n.t('settings.personal.general.parameters.stopSequence.description'),
|
|
kind: 'text',
|
|
initial: ''
|
|
},
|
|
{
|
|
key: 'reasoning_effort',
|
|
placeholder: $i18n.t('Enter reasoning effort'),
|
|
label: $i18n.t('settings.personal.general.parameters.reasoningEffort.label'),
|
|
tip: $i18n.t('settings.personal.general.parameters.reasoningEffort.description'),
|
|
kind: 'text',
|
|
initial: 'medium',
|
|
suggestions: ['none', 'minimal', 'low', 'medium', 'high']
|
|
},
|
|
{
|
|
key: 'logit_bias',
|
|
placeholder: $i18n.t(
|
|
'Enter comma-separated "token:bias_value" pairs (example: 5432:100, 413:-100)'
|
|
),
|
|
label: $i18n.t('settings.personal.general.parameters.logitBias.label'),
|
|
tip: $i18n.t(
|
|
'Boosting or penalizing specific tokens for constrained responses. Bias values will be clamped between -100 and 100 (inclusive). (Default: none)'
|
|
),
|
|
kind: 'text',
|
|
initial: ''
|
|
},
|
|
{
|
|
key: 'mirostat',
|
|
label: $i18n.t('settings.personal.general.parameters.mirostat.label'),
|
|
tip: $i18n.t('Enable Mirostat sampling for controlling perplexity.'),
|
|
kind: 'number',
|
|
initial: 0,
|
|
min: 0,
|
|
max: 2,
|
|
rangeStep: 1,
|
|
step: 1
|
|
},
|
|
{
|
|
key: 'mirostat_eta',
|
|
label: $i18n.t('settings.personal.general.parameters.mirostatEta.label'),
|
|
tip: $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.'
|
|
),
|
|
kind: 'number',
|
|
initial: 0.1,
|
|
min: 0,
|
|
max: 1,
|
|
rangeStep: 0.05,
|
|
step: 'any'
|
|
},
|
|
{
|
|
key: 'mirostat_tau',
|
|
label: $i18n.t('settings.personal.general.parameters.mirostatTau.label'),
|
|
tip: $i18n.t(
|
|
'Controls the balance between coherence and diversity of the output. A lower value will result in more focused and coherent text.'
|
|
),
|
|
kind: 'number',
|
|
initial: 5,
|
|
min: 0,
|
|
max: 10,
|
|
rangeStep: 0.5,
|
|
step: 'any'
|
|
},
|
|
{
|
|
key: 'repeat_last_n',
|
|
label: $i18n.t('settings.personal.general.parameters.repeatLastN.label'),
|
|
tip: $i18n.t('Sets how far back for the model to look back to prevent repetition.'),
|
|
kind: 'number',
|
|
initial: 64,
|
|
min: -1,
|
|
max: 128,
|
|
rangeStep: 1,
|
|
step: 1
|
|
},
|
|
{
|
|
key: 'tfs_z',
|
|
label: $i18n.t('settings.personal.general.parameters.tfsZ.label'),
|
|
tip: $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.'
|
|
),
|
|
kind: 'number',
|
|
initial: 1,
|
|
min: 0,
|
|
max: 2,
|
|
rangeStep: 0.05,
|
|
step: 'any'
|
|
},
|
|
{
|
|
key: 'repeat_penalty',
|
|
label: $i18n.t('settings.personal.general.parameters.repeatPenalty.label'),
|
|
tip: $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.'
|
|
),
|
|
kind: 'number',
|
|
initial: 1.1,
|
|
min: -2,
|
|
max: 2,
|
|
rangeStep: 0.05,
|
|
step: 'any'
|
|
},
|
|
{
|
|
key: 'think',
|
|
placeholder: $i18n.t("e.g. 'low', 'medium', 'high'"),
|
|
label: $i18n.t('settings.personal.general.parameters.think.label'),
|
|
tip: $i18n.t('settings.personal.general.parameters.ollama.description'),
|
|
kind: 'text',
|
|
initial: true,
|
|
suggestions: ['true', 'false', 'low', 'medium', 'high'],
|
|
ollama: true
|
|
},
|
|
{
|
|
key: 'format',
|
|
placeholder: $i18n.t('e.g. "json" or a JSON schema'),
|
|
label: $i18n.t('settings.personal.general.parameters.format.label'),
|
|
tip: $i18n.t('The format to return a response in. Format can be json or a JSON schema.'),
|
|
kind: 'text',
|
|
initial: 'json',
|
|
suggestions: ['json'],
|
|
ollama: true
|
|
},
|
|
{
|
|
key: 'num_keep',
|
|
label: $i18n.t('settings.personal.general.parameters.numKeep.label'),
|
|
tip: $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.'
|
|
),
|
|
kind: 'number',
|
|
initial: 24,
|
|
min: -1,
|
|
max: 10240000,
|
|
rangeStep: 1,
|
|
step: 1,
|
|
open: true,
|
|
ollama: true
|
|
},
|
|
{
|
|
key: 'num_ctx',
|
|
label: $i18n.t('settings.personal.general.parameters.numCtx.label'),
|
|
tip: $i18n.t('Sets the size of the context window used to generate the next token.'),
|
|
kind: 'number',
|
|
initial: 2048,
|
|
min: -1,
|
|
max: 10240000,
|
|
rangeStep: 1,
|
|
step: 1,
|
|
open: true,
|
|
ollama: true
|
|
},
|
|
{
|
|
key: 'num_batch',
|
|
label: $i18n.t('settings.personal.general.parameters.numBatch.label'),
|
|
tip: $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.'
|
|
),
|
|
kind: 'number',
|
|
initial: 512,
|
|
min: 256,
|
|
max: 8192,
|
|
rangeStep: 256,
|
|
step: 1,
|
|
open: true,
|
|
ollama: true
|
|
},
|
|
{
|
|
key: 'use_mmap',
|
|
label: $i18n.t('settings.personal.general.parameters.useMmap.label'),
|
|
tip: $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.'
|
|
),
|
|
kind: 'bool',
|
|
initial: true,
|
|
ollama: true,
|
|
adminOnly: true
|
|
},
|
|
{
|
|
key: 'use_mlock',
|
|
label: $i18n.t('settings.personal.general.parameters.useMlock.label'),
|
|
tip: $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."
|
|
),
|
|
kind: 'bool',
|
|
initial: true,
|
|
ollama: true,
|
|
adminOnly: true
|
|
},
|
|
{
|
|
key: 'num_thread',
|
|
label: $i18n.t('settings.personal.general.parameters.numThread.label'),
|
|
tip: $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.'
|
|
),
|
|
kind: 'number',
|
|
initial: 2,
|
|
min: 1,
|
|
max: 256,
|
|
rangeStep: 1,
|
|
step: 1,
|
|
ollama: true,
|
|
adminOnly: true
|
|
},
|
|
{
|
|
key: 'num_gpu',
|
|
label: $i18n.t('settings.personal.general.parameters.numGpu.label'),
|
|
tip: $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.'
|
|
),
|
|
kind: 'number',
|
|
initial: 0,
|
|
min: 0,
|
|
max: 256,
|
|
rangeStep: 1,
|
|
step: 1,
|
|
ollama: true,
|
|
adminOnly: true
|
|
},
|
|
{
|
|
key: 'keep_alive',
|
|
placeholder: $i18n.t("e.g. '30s','10m'. Valid time units are 's', 'm', 'h'."),
|
|
label: $i18n.t('settings.personal.general.parameters.keepAlive.label'),
|
|
tip: $i18n.t(
|
|
'This option controls how long the model will stay loaded into memory following the request (default: 5m)'
|
|
),
|
|
kind: 'text',
|
|
initial: '5m',
|
|
suggestions: ['5m', '30m', '1h', '-1'],
|
|
ollama: true,
|
|
adminOnly: true
|
|
}
|
|
];
|
|
|
|
// Name and value suggestions for provider parameters that are not built in.
|
|
const customSuggestions: Record<string, string[]> = {
|
|
service_tier: ['auto', 'default', 'flex', 'priority'],
|
|
reasoning: ['{"effort":"low"}', '{"effort":"medium"}', '{"effort":"high"}'],
|
|
verbosity: ['low', 'medium', 'high'],
|
|
text: ['{"verbosity":"low"}', '{"verbosity":"medium"}', '{"verbosity":"high"}'],
|
|
max_completion_tokens: [],
|
|
max_output_tokens: [],
|
|
parallel_tool_calls: ['true', 'false'],
|
|
tool_choice: ['auto', 'none', 'required'],
|
|
response_format: ['{"type":"text"}', '{"type":"json_object"}'],
|
|
repetition_penalty: [],
|
|
logprobs: ['true', 'false'],
|
|
top_logprobs: [],
|
|
prompt_cache_key: [],
|
|
store: ['true', 'false'],
|
|
provider: ['{"sort":"price"}', '{"sort":"throughput"}', '{"sort":"latency"}'],
|
|
num_predict: []
|
|
};
|
|
|
|
const pickerId = `params-${Math.random().toString(36).slice(2)}`;
|
|
|
|
$: available = modelParams.filter((param) => admin || !param.adminOnly);
|
|
$: setParams = available.filter((param) => (params?.[param.key] ?? null) !== null);
|
|
$: customParams = custom && admin ? Object.keys(params?.custom_params ?? {}) : [];
|
|
$: used = new Set([...setParams.map((param) => param.key), ...customParams]);
|
|
$: nameOptions = [
|
|
...available
|
|
.filter((param) => !used.has(param.key))
|
|
.map((param) => ({ id: param.key, name: labelOf(param), description: param.tip })),
|
|
...(custom && admin
|
|
? Object.keys(customSuggestions)
|
|
.filter((name) => !used.has(name))
|
|
.map((name) => ({ id: name, name }))
|
|
: [])
|
|
];
|
|
const suggestionItems = (options: string[]) =>
|
|
options.map((option) => ({ id: option, name: option }));
|
|
|
|
const labelOf = (param: ModelParam) =>
|
|
param.ollama
|
|
? `${param.label} (${$i18n.t('settings.personal.general.parameters.ollama.label')})`
|
|
: param.label;
|
|
|
|
const setParam = (key: string, value: unknown) => {
|
|
params = { ...params, [key]: value };
|
|
onParamChange(key, value);
|
|
};
|
|
|
|
const setCustom = (value: Record<string, unknown>) => {
|
|
params = { ...params, custom_params: value };
|
|
onParamChange('custom_params', value);
|
|
};
|
|
|
|
// Reject a fraction in a step="1" field instead of keeping or rounding it ("32.767" is usually 32767).
|
|
const setNumber = (key: string, event: Event) => {
|
|
const input = event.currentTarget as HTMLInputElement;
|
|
if (input.value === '' || input.validity.stepMismatch || input.validity.badInput) {
|
|
input.value = `${params[key] ?? ''}`;
|
|
return;
|
|
}
|
|
setParam(key, input.valueAsNumber);
|
|
};
|
|
|
|
// think accepts booleans as well as effort strings.
|
|
const toValue = (key: string, raw: string) =>
|
|
key === 'think' && (raw === 'true' || raw === 'false') ? raw === 'true' : raw;
|
|
|
|
// Accept a typed display name ("Temperature") as well as the key.
|
|
const byLabel = (name: string) =>
|
|
available.find((param) => labelOf(param).toLowerCase() === name.trim().toLowerCase())?.key ??
|
|
name.trim();
|
|
|
|
let newName = '';
|
|
const addParam = (name: string) => {
|
|
name = byLabel(name);
|
|
newName = '';
|
|
if (!name || used.has(name)) return;
|
|
const param = available.find((param) => param.key === name);
|
|
if (param) {
|
|
setParam(name, param.initial);
|
|
} else if (custom && admin) {
|
|
setCustom({ ...(params?.custom_params ?? {}), [name]: '' });
|
|
}
|
|
};
|
|
|
|
const customText = (name: string) => {
|
|
const value = params?.custom_params?.[name];
|
|
return typeof value === 'object' && value !== null ? JSON.stringify(value) : `${value ?? ''}`;
|
|
};
|
|
|
|
const rowLabelClass =
|
|
'self-center font-normal underline decoration-dotted decoration-base-400/70 underline-offset-4 dark:decoration-base-500';
|
|
const buttonClass =
|
|
'p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden font-normal text-base-900 dark:text-base-100';
|
|
const inputClass =
|
|
'text-sm w-full bg-transparent outline-hidden outline-none font-normal text-base-900 dark:text-base-100';
|
|
</script>
|
|
|
|
{#snippet rangeParam(param: ModelParam)}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<div class=" flex-1">
|
|
<input
|
|
type="range"
|
|
aria-label={labelOf(param)}
|
|
min={param.min}
|
|
max={param.max}
|
|
step={param.rangeStep}
|
|
value={params[param.key]}
|
|
on:input={(event) =>
|
|
(params = { ...params, [param.key]: event.currentTarget.valueAsNumber })}
|
|
on:change={() => onParamChange(param.key, params[param.key] ?? null)}
|
|
class="w-full h-2 rounded-lg appearance-none cursor-pointer dark:bg-base-700"
|
|
/>
|
|
</div>
|
|
<div>
|
|
<input
|
|
value={params[param.key]}
|
|
on:change={(event) => setNumber(param.key, event)}
|
|
type="number"
|
|
aria-label={labelOf(param)}
|
|
class=" bg-transparent text-center w-14"
|
|
min={param.min}
|
|
max={param.open ? undefined : param.max}
|
|
step={param.step ?? 'any'}
|
|
/>
|
|
</div>
|
|
</div>
|
|
{/snippet}
|
|
|
|
{#snippet removableRow(label: string, tip: string, mono: boolean, onRemove: () => void)}
|
|
<Tooltip content={tip} placement="top-start" className="inline-tooltip">
|
|
<UserSettingRow
|
|
className="w-full py-0.5"
|
|
labelClassName={tip ? rowLabelClass : 'self-center font-normal'}
|
|
>
|
|
<span slot="label" class={mono ? 'font-mono' : ''}>{label}</span>
|
|
<button
|
|
class="flex shrink-0 rounded-sm p-1 text-base-400 transition hover:text-base-700 dark:text-base-500 dark:hover:text-base-300"
|
|
type="button"
|
|
aria-label={`${$i18n.t('Remove')} ${label}`}
|
|
on:click={onRemove}
|
|
>
|
|
<XMark className="size-3" strokeWidth="2" />
|
|
</button>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
{/snippet}
|
|
|
|
{#snippet defaultRow(label: string, tip: string, value: string, onClick: () => void)}
|
|
<Tooltip content={tip} placement="top-start" className="inline-tooltip">
|
|
<UserSettingRow let:labelId className="w-full py-0.5" labelClassName={rowLabelClass}>
|
|
<span slot="label">{label}</span>
|
|
<button id={`${labelId}-control`} class={buttonClass} type="button" on:click={onClick}>
|
|
<span class="ml-2 self-center">{value}</span>
|
|
</button>
|
|
</UserSettingRow>
|
|
</Tooltip>
|
|
{/snippet}
|
|
|
|
<div
|
|
class={layout === 'grid'
|
|
? 'grid grid-cols-1 gap-x-5 gap-y-1 pb-safe-bottom text-xs text-base-900 dark:text-base-100 sm:grid-cols-2 lg:grid-cols-3'
|
|
: 'space-y-1 pb-safe-bottom text-xs text-base-900 dark:text-base-100'}
|
|
>
|
|
<!-- Open WebUI's own settings are always listed. -->
|
|
<div>
|
|
{@render defaultRow(
|
|
$i18n.t('settings.personal.general.parameters.streamChatResponse.label'),
|
|
$i18n.t('settings.personal.general.parameters.streamChatResponse.description'),
|
|
params?.stream_response === true
|
|
? $i18n.t('On')
|
|
: params?.stream_response === false
|
|
? $i18n.t('Off')
|
|
: $i18n.t('Default'),
|
|
() =>
|
|
setParam(
|
|
'stream_response',
|
|
(params?.stream_response ?? null) === null ? true : params.stream_response ? false : null
|
|
)
|
|
)}
|
|
</div>
|
|
|
|
{#if admin}
|
|
<div>
|
|
{@render defaultRow(
|
|
$i18n.t('settings.personal.general.parameters.streamDeltaChunkSize.label'),
|
|
$i18n.t('settings.personal.general.parameters.streamDeltaChunkSize.description'),
|
|
(params?.stream_delta_chunk_size ?? null) === null ? $i18n.t('Default') : $i18n.t('Custom'),
|
|
() =>
|
|
setParam(
|
|
'stream_delta_chunk_size',
|
|
(params?.stream_delta_chunk_size ?? null) === null ? 1 : null
|
|
)
|
|
)}
|
|
{#if (params?.stream_delta_chunk_size ?? null) !== null}
|
|
{@render rangeParam({
|
|
key: 'stream_delta_chunk_size',
|
|
label: $i18n.t('settings.personal.general.parameters.streamDeltaChunkSize.label'),
|
|
tip: '',
|
|
kind: 'number',
|
|
initial: 1,
|
|
min: 1,
|
|
max: 128,
|
|
rangeStep: 1,
|
|
step: 1,
|
|
open: true
|
|
})}
|
|
{/if}
|
|
</div>
|
|
{/if}
|
|
|
|
{#if admin && $config?.features?.enable_context_compaction}
|
|
<div>
|
|
{@render defaultRow(
|
|
$i18n.t('settings.personal.general.parameters.contextCompactionThreshold.label'),
|
|
$i18n.t('settings.personal.general.parameters.contextCompactionThreshold.description'),
|
|
(params?.compact_token_threshold ?? null) === null ? $i18n.t('Default') : $i18n.t('Custom'),
|
|
() =>
|
|
setParam(
|
|
'compact_token_threshold',
|
|
(params?.compact_token_threshold ?? null) === null ? 80000 : null
|
|
)
|
|
)}
|
|
{#if (params?.compact_token_threshold ?? null) !== null}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<input
|
|
class={inputClass}
|
|
type="number"
|
|
min="1"
|
|
step="1"
|
|
placeholder={$i18n.t('Enter token threshold')}
|
|
aria-label={$i18n.t(
|
|
'settings.personal.general.parameters.contextCompactionThreshold.label'
|
|
)}
|
|
value={params.compact_token_threshold}
|
|
on:change={(event) => setNumber('compact_token_threshold', event)}
|
|
/>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
{/if}
|
|
|
|
<div>
|
|
{@render defaultRow(
|
|
$i18n.t('settings.personal.general.parameters.functionCalling.label'),
|
|
$i18n.t('settings.personal.general.parameters.functionCalling.description'),
|
|
params?.function_calling === 'native'
|
|
? $i18n.t('Native')
|
|
: params?.function_calling === 'legacy'
|
|
? $i18n.t('Legacy')
|
|
: $i18n.t('Default'),
|
|
() =>
|
|
setParam(
|
|
'function_calling',
|
|
(params?.function_calling ?? null) === null
|
|
? 'native'
|
|
: params.function_calling === 'native'
|
|
? 'legacy'
|
|
: null
|
|
)
|
|
)}
|
|
</div>
|
|
|
|
<div>
|
|
{@render defaultRow(
|
|
$i18n.t('settings.personal.general.parameters.reasoningTags.label'),
|
|
$i18n.t('settings.personal.general.parameters.reasoningTags.description'),
|
|
(params?.reasoning_tags ?? null) === null
|
|
? $i18n.t('Default')
|
|
: params.reasoning_tags === true
|
|
? $i18n.t('Enabled')
|
|
: params.reasoning_tags === false
|
|
? $i18n.t('Disabled')
|
|
: $i18n.t('Custom'),
|
|
() =>
|
|
setParam(
|
|
'reasoning_tags',
|
|
(params?.reasoning_tags ?? null) === null
|
|
? ['', '']
|
|
: Array.isArray(params.reasoning_tags)
|
|
? true
|
|
: params.reasoning_tags === true
|
|
? false
|
|
: null
|
|
)
|
|
)}
|
|
{#if Array.isArray(params?.reasoning_tags) && params.reasoning_tags.length === 2}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<div class=" flex-1">
|
|
<input
|
|
class={inputClass}
|
|
type="text"
|
|
aria-label={$i18n.t('Start Tag')}
|
|
placeholder={$i18n.t('Start Tag')}
|
|
value={params.reasoning_tags[0]}
|
|
on:change={(event) =>
|
|
setParam('reasoning_tags', [event.currentTarget.value, params.reasoning_tags[1]])}
|
|
autocomplete="off"
|
|
/>
|
|
</div>
|
|
<div class=" flex-1">
|
|
<input
|
|
class={inputClass}
|
|
type="text"
|
|
aria-label={$i18n.t('End Tag')}
|
|
placeholder={$i18n.t('End Tag')}
|
|
value={params.reasoning_tags[1]}
|
|
on:change={(event) =>
|
|
setParam('reasoning_tags', [params.reasoning_tags[0], event.currentTarget.value])}
|
|
autocomplete="off"
|
|
/>
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
<!-- Model parameters that are set. Custom resets to Default, which removes the row. -->
|
|
{#each setParams as param (param.key)}
|
|
<div>
|
|
{@render removableRow(labelOf(param), param.tip, false, () => setParam(param.key, null))}
|
|
{#if param.kind === 'bool'}
|
|
<UserSettingRow let:labelId className="mt-1">
|
|
<span slot="label">
|
|
{params[param.key] ? $i18n.t('Enabled') : $i18n.t('Disabled')}
|
|
</span>
|
|
<div class=" pr-2">
|
|
<Switch
|
|
ariaLabelledbyId={labelId}
|
|
state={!!params[param.key]}
|
|
on:change={(event) => setParam(param.key, event.detail)}
|
|
ariaLabel={labelOf(param)}
|
|
/>
|
|
</div>
|
|
</UserSettingRow>
|
|
{:else if param.kind === 'number' && param.max !== undefined}
|
|
{@render rangeParam(param)}
|
|
{:else if param.kind === 'number'}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<input
|
|
class={inputClass}
|
|
type="number"
|
|
min={param.min}
|
|
step={param.step ?? 'any'}
|
|
placeholder={param.placeholder ?? labelOf(param)}
|
|
aria-label={labelOf(param)}
|
|
value={params[param.key]}
|
|
on:change={(event) => setNumber(param.key, event)}
|
|
autocomplete="off"
|
|
/>
|
|
</div>
|
|
{:else if param.suggestions}
|
|
<div
|
|
class="flex mt-0.5 text-sm"
|
|
on:focusout={(event) =>
|
|
setParam(param.key, toValue(param.key, (event.target as HTMLInputElement).value))}
|
|
>
|
|
<TTSVoiceInput
|
|
limit={null}
|
|
minWidth={384}
|
|
showDescription
|
|
popupClassName="max-w-[calc(100vw-1rem)] max-h-64 rounded-xl border border-base-200 bg-base-0 p-1 shadow-lg dark:border-base-800 dark:bg-base-850"
|
|
id={`${pickerId}-${param.key}`}
|
|
value={`${params[param.key] ?? ''}`}
|
|
voices={suggestionItems(param.suggestions)}
|
|
on:select={(event) => setParam(param.key, toValue(param.key, event.detail.id))}
|
|
placeholder={param.placeholder ?? labelOf(param)}
|
|
/>
|
|
</div>
|
|
{:else}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<input
|
|
class={inputClass}
|
|
type="text"
|
|
autocomplete="off"
|
|
placeholder={param.placeholder ?? labelOf(param)}
|
|
aria-label={labelOf(param)}
|
|
value={params[param.key]}
|
|
on:change={(event) =>
|
|
setParam(param.key, toValue(param.key, event.currentTarget.value))}
|
|
/>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
{/each}
|
|
|
|
{#each customParams as name (name)}
|
|
{@const options = customSuggestions[name] ?? []}
|
|
<div>
|
|
{@render removableRow(name, '', true, () => {
|
|
const { [name]: _, ...rest } = params.custom_params;
|
|
setCustom(rest);
|
|
})}
|
|
{#if options.length === 2 && options.includes('true') && options.includes('false')}
|
|
<!-- Saved as text, as the old free-text field did. -->
|
|
<UserSettingRow let:labelId className="mt-1">
|
|
<span slot="label">
|
|
{`${params.custom_params[name]}` === 'true' ? $i18n.t('Enabled') : $i18n.t('Disabled')}
|
|
</span>
|
|
<div class=" pr-2">
|
|
<Switch
|
|
ariaLabelledbyId={labelId}
|
|
state={`${params.custom_params[name]}` === 'true'}
|
|
on:change={(event) =>
|
|
setCustom({ ...params.custom_params, [name]: event.detail ? 'true' : 'false' })}
|
|
ariaLabel={name}
|
|
/>
|
|
</div>
|
|
</UserSettingRow>
|
|
{:else if options.length}
|
|
<div
|
|
class="flex mt-0.5 text-sm"
|
|
on:focusout={(event) =>
|
|
setCustom({
|
|
...params.custom_params,
|
|
[name]: (event.target as HTMLInputElement).value
|
|
})}
|
|
>
|
|
<TTSVoiceInput
|
|
limit={null}
|
|
minWidth={384}
|
|
showDescription
|
|
popupClassName="max-w-[calc(100vw-1rem)] max-h-64 rounded-xl border border-base-200 bg-base-0 p-1 shadow-lg dark:border-base-800 dark:bg-base-850"
|
|
id={`${pickerId}-custom-${name}`}
|
|
value={customText(name)}
|
|
voices={suggestionItems(options)}
|
|
on:select={(event) => setCustom({ ...params.custom_params, [name]: event.detail.id })}
|
|
placeholder={$i18n.t('Custom Parameter Value')}
|
|
/>
|
|
</div>
|
|
{:else}
|
|
<div class="flex mt-0.5 space-x-2">
|
|
<input
|
|
class={inputClass}
|
|
type="text"
|
|
autocomplete="off"
|
|
placeholder={$i18n.t('Custom Parameter Value')}
|
|
aria-label={name}
|
|
value={customText(name)}
|
|
on:change={(event) =>
|
|
setCustom({ ...params.custom_params, [name]: event.currentTarget.value })}
|
|
/>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
{/each}
|
|
|
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
<div
|
|
class="flex items-center gap-2 py-0.5 {layout === 'grid' ? 'max-sm:mt-2' : 'mt-2'}"
|
|
on:keydown={(event) => {
|
|
// Enter on typed text adds it; picking a suggestion is handled by on:select.
|
|
if (event.key === 'Enter' && newName.trim()) {
|
|
event.preventDefault();
|
|
addParam(newName);
|
|
}
|
|
}}
|
|
>
|
|
<TTSVoiceInput
|
|
limit={null}
|
|
showDescription
|
|
popupClassName="max-w-[calc(100vw-1rem)] max-h-64 rounded-xl border border-base-200 bg-base-0 p-1 shadow-lg dark:border-base-800 dark:bg-base-850"
|
|
id={`${pickerId}-add`}
|
|
bind:value={newName}
|
|
voices={nameOptions}
|
|
placeholder={$i18n.t('Add parameter')}
|
|
on:select={(event) => addParam(event.detail.id)}
|
|
/>
|
|
<button
|
|
type="button"
|
|
class="flex shrink-0 rounded-sm p-1 text-base-400 transition hover:text-base-700 disabled:opacity-40 dark:text-base-500 dark:hover:text-base-300"
|
|
aria-label={$i18n.t('Add parameter')}
|
|
disabled={!newName.trim()}
|
|
on:click={() => addParam(newName)}
|
|
>
|
|
<Plus className="size-3" strokeWidth="2" />
|
|
</button>
|
|
</div>
|
|
</div>
|