Skip to content

webui: use server presets as parameter placeholders - #18226

Closed
ServeurpersoCom wants to merge 25 commits into
ggml-org:masterfrom
ServeurpersoCom:webui/sampling-from-preset
Closed

ServeurpersoCom wants to merge 25 commits into
ggml-org:masterfrom
ServeurpersoCom:webui/sampling-from-preset

Conversation

@ServeurpersoCom

@ServeurpersoCom ServeurpersoCom commented Dec 20, 2025 •

Copy link
Copy Markdown
Contributor

Make sure to read the contributing guidelines before submitting a PR

WebUI now displays dynamic parameter placeholders from server/model defaults instead of hardcoded values. Sampling parameters are removed from static defaults - the backend becomes the source of truth while users can still override when needed.

Changes:

  • Remove hardcoded sampling parameters from SETTING_CONFIG_DEFAULT
  • Add getParameterPlaceholder(): model presets -> server defaults -> "none"
  • Support both router mode (per-model /props?model=X) and single-model mode (/props)
  • Unify "Custom" parameter badge logic across both modes - badge appears when user value differs from current placeholder

Behavior:

  • When no user override is set, server automatically uses its presets (or defaults if no preset available) -> webui don't send this API field.
  • Parameter placeholders are reactive and automatically update when switching models
  • Displays current model's preset values from default_generation_settings.params
  • User overrides are stored globally in localStorage (not per-model)
  • Per-model overrides can be implemented as future enhancement

Demo:

Backend-Params.mp4

Close #18129

@allozaur allozaur left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few remarks

@ServeurpersoCom

ServeurpersoCom commented Dec 23, 2025 •

Copy link
Copy Markdown
Contributor Author

Now there's just one small refactoring left:

In single-model mode, the "Custom" badge logic is inverted. It should only display when overriding with a value (different from the placeholder / or for non-empty field).

SingleModelBug1 SingleModelBug2

In multi-model (router) mode -> the badge doesn't appear at all -> we need to unify the behavior across both modes, then we'll be good to go!

OK on last commit (unified behavior)

@ServeurpersoCom

ServeurpersoCom commented Dec 25, 2025 •

Copy link
Copy Markdown
Contributor Author

Everything is customizable via --webui-config-file.

The JSON parameters will be:

  1. Loaded on all new browsers (first visit)
  2. Customizable per browser and stored in localStorage
  3. Resettable via "Reset to default" button to restore server defaults

Sampling parameters can also be forced via this JSON, but it's recommended to leave them undefined so the backend can provide its defaults. This allows presets.ini in router mode to control them per-model.

I think we're complete now, except maybe the "system" selector being empty by default,
I'm thinking of modifying the code to auto-select the first item in the list when undefined (system).

What do you think @allozaur, good refactoring? Feel free to nitpick or ask for further refactoring: variable renames, structure changes...

{
  "apiKey": "",
  "systemMessage": "",
  "showSystemMessage": true,
  "theme": "system",
  "pasteLongTextToFileLen": 2500,
  "copyTextAttachmentsAsPlainText": false,
  "pdfAsImage": false,
  "showThoughtInProgress": false,
  "showToolCalls": false,
  "disableReasoningFormat": false,
  "alwaysShowSidebarOnDesktop": false,
  "autoShowSidebarOnNewChat": true,
  "keepStatsVisible": false,
  "showMessageStats": true,
  "askForTitleConfirmation": false,
  "disableAutoScroll": false,
  "renderUserContentAsMarkdown": false,
  "autoMicOnEmpty": false,
  "custom": "",
  "pyInterpreterEnabled": false,
  "enableContinueGeneration": false
}

@ServeurpersoCom
ServeurpersoCom force-pushed the webui/sampling-from-preset branch from 62cffb0 to 9a86a5f Compare December 25, 2025 12:22
@ServeurpersoCom

Copy link
Copy Markdown
Contributor Author

Rebased / static build

@ServeurpersoCom
ServeurpersoCom force-pushed the webui/sampling-from-preset branch from 9a86a5f to 93eb337 Compare December 25, 2025 12:38
@ServeurpersoCom
ServeurpersoCom force-pushed the webui/sampling-from-preset branch from 45e9de2 to d2b9097 Compare December 25, 2025 17:37
@ServeurpersoCom

ServeurpersoCom commented Dec 25, 2025 •

Copy link
Copy Markdown
Contributor Author

finish the config() -> getConfig() refactor we started

Turns out removing SETTING_CONFIG_DEFAULT was only step 1. Step 2:
actually use settingsStore.getConfig() everywhere instead of raw
config() access. 20+ files migrated to proper API with type fallbacks

@allozaur allozaur left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ServeurpersoCom overall great stuff, but architecturally i think it'd be good to address the way how we are getting the config into the stores and components.

@ServeurpersoCom

Copy link
Copy Markdown
Contributor Author

There is still work to be done (+ doc update) :

(root|~/llama.cpp.pascal/tools/server/webui) git grep "config()"
docs/architecture/high-level-architecture.md:                RE35["config()"]
src/lib/components/app/chat/ChatForm/ChatForm.svelte:   let currentConfig = $derived(config());
src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActions.svelte:    let currentConfig = $derived(config());
src/lib/components/app/chat/ChatMessages/ChatMessageAssistant.svelte:   let currentConfig = $derived(config());
src/lib/components/app/chat/ChatMessages/ChatMessageEditForm.svelte:    let currentConfig = $derived(config());
src/lib/components/app/chat/ChatSettings/ChatSettings.svelte:   let localConfig: SettingsConfigType = $state({ ...config() });
src/lib/components/app/chat/ChatSettings/ChatSettings.svelte:           localConfig = { ...config() };
src/lib/components/app/chat/ChatSettings/ChatSettings.svelte:           localConfig = { ...config() };
src/lib/services/chat.ts:                       const agenticConfig = mcpClient ? getAgenticConfig(config()) : undefined;
src/lib/services/mcp-singleton.ts:      const mcpConfig = buildMcpClientConfig(config());
src/lib/services/mcp-singleton.ts:      const mcpConfig = buildMcpClientConfig(config());
src/lib/stores/chat.svelte.ts:          const currentConfig = config();
src/lib/stores/chat.svelte.ts:          const currentConfig = config();
(root|~/llama.cpp.pascal/tools/server/webui) git grep SETTING_CONFIG_DEFAULT
docs/flows/settings-flow.md:        settingsStore->>settingsStore: Merge with SETTING_CONFIG_DEFAULT
docs/flows/settings-flow.md:        settingsStore->>settingsStore: config = SETTING_CONFIG_DEFAULT
docs/flows/settings-flow.md:    settingsStore->>settingsStore: config = SETTING_CONFIG_DEFAULT
(root|~/llama.cpp.pascal/tools/server/webui) git grep "currentConfig"
src/lib/components/app/chat/ChatForm/ChatForm.svelte:   let currentConfig = $derived(config());
src/lib/components/app/chat/ChatForm/ChatForm.svelte:           const n = Number(currentConfig.pasteLongTextToFileLen);
src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActions.svelte:    let currentConfig = $derived(config());
src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActions.svelte:            hasAudioModality && !hasText && !hasAudioAttachments && currentConfig.autoMicOnEmpty
src/lib/components/app/chat/ChatMessages/ChatMessageAssistant.svelte:   let currentConfig = $derived(config());
src/lib/components/app/chat/ChatMessages/ChatMessageAssistant.svelte:                           {:else if isLoading() && currentConfig.showMessageStats}
src/lib/components/app/chat/ChatMessages/ChatMessageEditForm.svelte:    let currentConfig = $derived(config());
src/lib/components/app/chat/ChatMessages/ChatMessageEditForm.svelte:            const n = Number(currentConfig.pasteLongTextToFileLen);
src/lib/stores/chat.svelte.ts:          const currentConfig = config();
src/lib/stores/chat.svelte.ts:                  temperature: currentConfig.temperature ?? 0.8,
src/lib/stores/chat.svelte.ts:                  topP: currentConfig.top_p ?? 0.95,
src/lib/stores/chat.svelte.ts:          const currentConfig = config();
src/lib/stores/chat.svelte.ts:          if (currentConfig.disableReasoningFormat) apiOptions.disableReasoningFormat = true;
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.temperature))
src/lib/stores/chat.svelte.ts:                  apiOptions.temperature = Number(currentConfig.temperature);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.dynatemp_range))
src/lib/stores/chat.svelte.ts:                  apiOptions.dynatemp_range = Number(currentConfig.dynatemp_range);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.dynatemp_exponent))
src/lib/stores/chat.svelte.ts:                  apiOptions.dynatemp_exponent = Number(currentConfig.dynatemp_exponent);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.top_k)) apiOptions.top_k = Number(currentConfig.top_k);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.top_p)) apiOptions.top_p = Number(currentConfig.top_p);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.min_p)) apiOptions.min_p = Number(currentConfig.min_p);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.xtc_probability))
src/lib/stores/chat.svelte.ts:                  apiOptions.xtc_probability = Number(currentConfig.xtc_probability);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.xtc_threshold))
src/lib/stores/chat.svelte.ts:                  apiOptions.xtc_threshold = Number(currentConfig.xtc_threshold);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.typ_p)) apiOptions.typ_p = Number(currentConfig.typ_p);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.repeat_last_n))
src/lib/stores/chat.svelte.ts:                  apiOptions.repeat_last_n = Number(currentConfig.repeat_last_n);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.repeat_penalty))
src/lib/stores/chat.svelte.ts:                  apiOptions.repeat_penalty = Number(currentConfig.repeat_penalty);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.presence_penalty))
src/lib/stores/chat.svelte.ts:                  apiOptions.presence_penalty = Number(currentConfig.presence_penalty);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.frequency_penalty))
src/lib/stores/chat.svelte.ts:                  apiOptions.frequency_penalty = Number(currentConfig.frequency_penalty);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.dry_multiplier))
src/lib/stores/chat.svelte.ts:                  apiOptions.dry_multiplier = Number(currentConfig.dry_multiplier);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.dry_base)) apiOptions.dry_base = Number(currentConfig.dry_base);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.dry_allowed_length))
src/lib/stores/chat.svelte.ts:                  apiOptions.dry_allowed_length = Number(currentConfig.dry_allowed_length);
src/lib/stores/chat.svelte.ts:          if (hasValue(currentConfig.dry_penalty_last_n))
src/lib/stores/chat.svelte.ts:                  apiOptions.dry_penalty_last_n = Number(currentConfig.dry_penalty_last_n);
src/lib/stores/chat.svelte.ts:          if (currentConfig.samplers) apiOptions.samplers = currentConfig.samplers;
src/lib/stores/chat.svelte.ts:          if (currentConfig.custom) apiOptions.custom = currentConfig.custom;
src/lib/utils/process-uploaded-files.ts:                                const currentConfig = settingsStore.config;
src/lib/utils/process-uploaded-files.ts:                                if (hasVisionSupport && !currentConfig.pdfAsImage) {

@ServeurpersoCom
ServeurpersoCom force-pushed the webui/sampling-from-preset branch from b5516ca to d18b8d7 Compare December 29, 2025 18:56
ServeurpersoCom and others added 8 commits December 30, 2025 00:04
WebUI sampling parameters now default to null and display server
presets (from models.ini or CLI args) as placeholders instead of
hardcoded defaults. This allows the backend to be the source of
truth while users can still override parameters when needed
…atSettingsFields.svelte

Co-authored-by: Aleksander Grygier <[email protected]>
…atSettingsFields.svelte

Co-authored-by: Aleksander Grygier <[email protected]>
ServeurpersoCom and others added 17 commits December 30, 2025 00:04
Remove SETTING_CONFIG_DEFAULT and canSync flag, all settings now
sourced from server /props webui_settings. Admin configures UI
defaults via --webui-config-file. Config starts empty, populated
from server. Placeholder falls back to 'none' when unavailable
Unify theme naming: remove leftover 'auto' references, use 'system'
consistently (matches UI label and JSON config)
Introspect SYNCABLE_PARAMETERS types for intelligent defaults,
eliminates manual ?? false throughout codebase
…atMessageEditForm.svelte

Co-authored-by: Aleksander Grygier <[email protected]>
Address review feedback from allozaur
- Clean up unused config imports
- Refactor getApiOptions: replace 40-line if-chain with loop
- Remove dead ApiProcessingState fields (temperature, topP, speculative)
@ServeurpersoCom
ServeurpersoCom force-pushed the webui/sampling-from-preset branch from 878aeb6 to a37e6b0 Compare December 29, 2025 23:06
@allozaur
allozaur self-requested a review December 30, 2025 12:47
@ServeurpersoCom

Copy link
Copy Markdown
Contributor Author

I think we'll go through the MCP first, it still needs improvement, for example with the JSON schema verification that we already use for toolcalls

@ServeurpersoCom
ServeurpersoCom marked this pull request as draft January 11, 2026 11:55
@ServeurpersoCom

Copy link
Copy Markdown
Contributor Author

Superseded by many PR/refactors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misc. bug: Web-Frontend overrides sampling parameters from models preset in router mode

2 participants