Add PRESERVE_THINKING and REASONING_EFFORT_PRESERVE_THINKING placeholders and update UI visibility

This commit is contained in:
extio-de
2026-08-15 21:22:24 +02:00
parent a6e57dec5e
commit 9567cfda0a
4 changed files with 29 additions and 23 deletions

View File

@@ -46,6 +46,8 @@ Use these tokens in app arguments:
- `TOP_K` - `TOP_K`
- `MIN_P` - `MIN_P`
- `REASONING_EFFORT` - `REASONING_EFFORT`
- `PRESERVE_THINKING`
- `REASONING_EFFORT_PRESERVE_THINKING`
- `REASONING_STOP` - `REASONING_STOP`
Example: Example:
@@ -56,8 +58,10 @@ Example:
For llama-server reasoning controls, configure `--chat-template-kwargs REASONING_EFFORT`. For llama-server reasoning controls, configure `--chat-template-kwargs REASONING_EFFORT`.
The placeholder expands to a single JSON argument such as `{"reasoning_effort": "medium"}`. The placeholder expands to a single JSON argument such as `{"reasoning_effort": "medium"}`.
When this placeholder is selected for the current app and model, the model options panel provides `PRESERVE_THINKING` expands to `{"preserve_thinking": true}`, while
the presets `none`, `low`, `medium`, `high`, and `xhigh`. `REASONING_EFFORT_PRESERVE_THINKING` combines both settings in one kwargs JSON argument.
The model options panel always provides the reasoning-effort presets `none`, `low`, `medium`,
`high`, and `xhigh`.
## Setup ## Setup

View File

@@ -18,17 +18,19 @@ record App(Path path, Path interpreter, @Deprecated List<String> arguments, List
modelSettings = modelSettings == null ? new ArrayList<>() : modelSettings; modelSettings = modelSettings == null ? new ArrayList<>() : modelSettings;
} }
static Map<String, Function<Model, String>> PLACEHOLDERS = Map.of( static Map<String, Function<Model, String>> PLACEHOLDERS = Map.ofEntries(
"MODEL", m -> m.path(), Map.entry("MODEL", m -> m.path()),
"CONTEXT_SIZE", m -> String.valueOf(m.contextSize()), Map.entry("CONTEXT_SIZE", m -> String.valueOf(m.contextSize())),
"THREADS", m -> String.valueOf(m.threads()), Map.entry("THREADS", m -> String.valueOf(m.threads())),
"GPU_LAYERS", m -> String.valueOf(m.gpuLayers()), Map.entry("GPU_LAYERS", m -> String.valueOf(m.gpuLayers())),
"TEMP", Model::temperatureDisplay, Map.entry("TEMP", Model::temperatureDisplay),
"TOP_P", Model::topPDisplay, Map.entry("TOP_P", Model::topPDisplay),
"TOP_K", Model::topKDisplay, Map.entry("TOP_K", Model::topKDisplay),
"MIN_P", Model::minPDisplay, Map.entry("MIN_P", Model::minPDisplay),
"REASONING_EFFORT", Model::reasoningEffortArgument, Map.entry("REASONING_EFFORT", Model::reasoningEffortArgument),
"REASONING_STOP", m -> "... thinking budget exceeded, let's answer now.\n"); Map.entry("PRESERVE_THINKING", Model::preserveThinkingArgument),
Map.entry("REASONING_EFFORT_PRESERVE_THINKING", Model::reasoningEffortPreserveThinkingArgument),
Map.entry("REASONING_STOP", m -> "... thinking budget exceeded, let's answer now.\n"));
String argumentsToString(final boolean showAll) { String argumentsToString(final boolean showAll) {
return this.argumentsToStringByArgs(this.appArguments.stream(), showAll); return this.argumentsToStringByArgs(this.appArguments.stream(), showAll);

View File

@@ -695,16 +695,8 @@ public class LaunchFrame extends JFrame {
} }
private void updateReasoningEffortVisibility() { private void updateReasoningEffortVisibility() {
boolean selected = false; this.lblReasoningEffort.setVisible(true);
for (int i = 0; i < this.appArgumentsTableModel.getRowCount(); i++) { this.comboReasoningEffort.setVisible(true);
final AppArgument argument = (AppArgument) this.appArgumentsTableModel.getValueAt(i, 0);
if ("REASONING_EFFORT".equals(argument.argument()) && (!argument.optional() || argument.default_())) {
selected = true;
break;
}
}
this.lblReasoningEffort.setVisible(selected);
this.comboReasoningEffort.setVisible(selected);
this.panel_3.revalidate(); this.panel_3.revalidate();
this.panel_3.repaint(); this.panel_3.repaint();
} }

View File

@@ -50,6 +50,14 @@ record Model(String path, int contextSize, int maxContextSize, int gpuLayers, in
return "{\"reasoning_effort\": \"" + this.reasoningEffort + "\"}"; return "{\"reasoning_effort\": \"" + this.reasoningEffort + "\"}";
} }
String preserveThinkingArgument() {
return "{\"preserve_thinking\": true}";
}
String reasoningEffortPreserveThinkingArgument() {
return "{\"reasoning_effort\": \"" + this.reasoningEffort + "\", \"preserve_thinking\": true}";
}
private static boolean isValidReasoningEffort(final String value) { private static boolean isValidReasoningEffort(final String value) {
for (final String effort : REASONING_EFFORTS) { for (final String effort : REASONING_EFFORTS) {
if (effort.equals(value)) { if (effort.equals(value)) {