Skip to content

Fix WebUI thinking mode request handling - #21657

Closed
redyuan43 wants to merge 2 commits into
ggml-org:masterfrom
redyuan43:codex/webui-thinking-sampling-presets
Closed

Fix WebUI thinking mode request handling#21657
redyuan43 wants to merge 2 commits into
ggml-org:masterfrom
redyuan43:codex/webui-thinking-sampling-presets

Conversation

@redyuan43

Copy link
Copy Markdown

Summary

  • decouple sampling presets from thinking mode in the WebUI
  • map WebUI Thinking mode to chat_template_kwargs.enable_thinking so on/off works for llama.cpp chat templates
  • disable reasoning parsing when Thinking mode is set to Off

Testing

  • npm run check
  • npm run build
  • rebuilt llama-server and verified a request with thinking disabled returns plain content without reasoning output

@redyuan43
redyuan43 requested a review from a team as a code owner April 9, 2026 04:55
@ggml-gh-bot

ggml-gh-bot Bot commented Apr 9, 2026

Copy link
Copy Markdown

Hi @redyuan43, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • Large PR: Large changes require prior discussion (e.g. an issue or RFC) and maintainers may not be able to review this PR as-is. Consider splitting it into smaller, focused PRs.

Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

// Strip reasoning content from context before sending
excludeReasoningFromContext?: boolean;
// Thinking behavior for supported models
thinking?: 'auto' | 'on' | 'off';

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.

should be an enum

let { onSave, initialSection }: Props = $props();

const settingSections: Array<{
type ModelFamily = 'gemma' | 'qwen' | 'unknown';

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.

should be enum

Comment on lines +56 to +120
const SAMPLING_PRESET_TRACKED_KEYS = [
SETTINGS_KEYS.TEMPERATURE,
SETTINGS_KEYS.TOP_K,
SETTINGS_KEYS.TOP_P,
SETTINGS_KEYS.MIN_P,
SETTINGS_KEYS.REPEAT_PENALTY,
SETTINGS_KEYS.PRESENCE_PENALTY
] as const;

const SAMPLING_PRESET_CONFIG: Record<
Exclude<ModelFamily, 'unknown'>,
Record<Exclude<SamplingPresetMode, 'custom'>, SamplingPresetConfig>
> = {
gemma: {
general: {
temperature: 1.0,
top_k: 64,
top_p: 0.95
},
precise: {
temperature: 0.2,
top_k: 64,
top_p: 0.95
}
},
qwen: {
general: {
temperature: 1.0,
top_k: 20,
top_p: 0.95,
min_p: 0.0,
repeat_penalty: 1.0,
presence_penalty: 1.5
},
precise: {
temperature: 0.6,
top_k: 20,
top_p: 0.95,
min_p: 0.0,
repeat_penalty: 1.0,
presence_penalty: 0.0
}
}
};

const SAMPLING_PRESET_OPTIONS: Record<
ModelFamily,
Array<{ value: SamplingPresetMode; label: string }>
> = {
gemma: [
{ value: 'general', label: 'General (Gemma chat)' },
{ value: 'precise', label: 'Precise (Gemma code/facts)' },
{ value: 'custom', label: 'Custom' }
],
qwen: [
{ value: 'general', label: 'General (Qwen chat)' },
{ value: 'precise', label: 'Precise (Qwen code)' },
{ value: 'custom', label: 'Custom' }
],
unknown: [
{ value: 'general', label: 'General' },
{ value: 'precise', label: 'Precise' },
{ value: 'custom', label: 'Custom' }
]
};

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.

these constants should be moved to $lib/constants

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.

Also, I feel that this presets logic could be encapsulated in a hook in $lib/hooks

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants