mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-08-12 22:31:11 +04:00
feat: Clamp and style numeric settings inputs from registry bounds
This commit is contained in:
committed by
Pascal
parent
acccabe7e5
commit
cd1832b9fe
@@ -98,7 +98,12 @@
|
||||
const numValue = Number(processedConfig[field]);
|
||||
if (!isNaN(numValue)) {
|
||||
if ((POSITIVE_INTEGER_FIELDS as readonly string[]).includes(field)) {
|
||||
processedConfig[field] = Math.max(1, Math.round(numValue));
|
||||
const entryByMinMax = SETTINGS_CHAT_SECTIONS.flatMap(
|
||||
(section) => section.fields ?? []
|
||||
).find((entry) => entry.key === field);
|
||||
const lo = entryByMinMax?.min ?? 1;
|
||||
const hi = entryByMinMax?.max ?? Number.POSITIVE_INFINITY;
|
||||
processedConfig[field] = Math.max(lo, Math.min(hi, Math.round(numValue)));
|
||||
} else {
|
||||
processedConfig[field] = numValue;
|
||||
}
|
||||
|
||||
@@ -83,12 +83,18 @@
|
||||
<Input
|
||||
id={field.key}
|
||||
type={field.isPositiveInteger ? 'number' : 'text'}
|
||||
{...field.isPositiveInteger ? { min: '1', step: '1' } : {}}
|
||||
{...field.isPositiveInteger
|
||||
? {
|
||||
min: String(field.min ?? 1),
|
||||
step: '1',
|
||||
...(field.max != null ? { max: String(field.max) } : {})
|
||||
}
|
||||
: {}}
|
||||
value={currentValue}
|
||||
oninput={(e) => onConfigChange(field.key, e.currentTarget.value)}
|
||||
placeholder={currentModelParams[field.key] != null
|
||||
? `Default: ${normalizeFloatingPoint(currentModelParams[field.key])}`
|
||||
: ''}
|
||||
: (field.placeholder ?? '')}
|
||||
class="w-full {isCustomRealTime ? 'pr-8' : ''}"
|
||||
/>
|
||||
{#if isCustomRealTime}
|
||||
|
||||
@@ -716,6 +716,9 @@ export const SETTINGS_CHAT_SECTIONS: SettingsSection[] = [
|
||||
type: s.type,
|
||||
isExperimental: s.isExperimental,
|
||||
isPositiveInteger: s.isPositiveInteger,
|
||||
placeholder: s.placeholder,
|
||||
min: s.min,
|
||||
max: s.max,
|
||||
dependsOn: s.dependsOn,
|
||||
help: s.help,
|
||||
options: s.options,
|
||||
|
||||
Reference in New Issue
Block a user