From 9567cfda0a85fad718b1c102e3696f3777c2fbc9 Mon Sep 17 00:00:00 2001 From: extio-de Date: Sat, 15 Aug 2026 21:22:24 +0200 Subject: [PATCH] Add PRESERVE_THINKING and REASONING_EFFORT_PRESERVE_THINKING placeholders and update UI visibility --- README.md | 8 ++++++-- src/de/extio/lm_launcher/App.java | 24 ++++++++++++----------- src/de/extio/lm_launcher/LaunchFrame.java | 12 ++---------- src/de/extio/lm_launcher/Model.java | 8 ++++++++ 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 856d106..6553d21 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,8 @@ Use these tokens in app arguments: - `TOP_K` - `MIN_P` - `REASONING_EFFORT` +- `PRESERVE_THINKING` +- `REASONING_EFFORT_PRESERVE_THINKING` - `REASONING_STOP` Example: @@ -56,8 +58,10 @@ Example: For llama-server reasoning controls, configure `--chat-template-kwargs REASONING_EFFORT`. 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 -the presets `none`, `low`, `medium`, `high`, and `xhigh`. +`PRESERVE_THINKING` expands to `{"preserve_thinking": true}`, while +`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 diff --git a/src/de/extio/lm_launcher/App.java b/src/de/extio/lm_launcher/App.java index 1cce647..81373d8 100644 --- a/src/de/extio/lm_launcher/App.java +++ b/src/de/extio/lm_launcher/App.java @@ -18,17 +18,19 @@ record App(Path path, Path interpreter, @Deprecated List arguments, List modelSettings = modelSettings == null ? new ArrayList<>() : modelSettings; } - static Map> PLACEHOLDERS = Map.of( - "MODEL", m -> m.path(), - "CONTEXT_SIZE", m -> String.valueOf(m.contextSize()), - "THREADS", m -> String.valueOf(m.threads()), - "GPU_LAYERS", m -> String.valueOf(m.gpuLayers()), - "TEMP", Model::temperatureDisplay, - "TOP_P", Model::topPDisplay, - "TOP_K", Model::topKDisplay, - "MIN_P", Model::minPDisplay, - "REASONING_EFFORT", Model::reasoningEffortArgument, - "REASONING_STOP", m -> "... thinking budget exceeded, let's answer now.\n"); + static Map> PLACEHOLDERS = Map.ofEntries( + Map.entry("MODEL", m -> m.path()), + Map.entry("CONTEXT_SIZE", m -> String.valueOf(m.contextSize())), + Map.entry("THREADS", m -> String.valueOf(m.threads())), + Map.entry("GPU_LAYERS", m -> String.valueOf(m.gpuLayers())), + Map.entry("TEMP", Model::temperatureDisplay), + Map.entry("TOP_P", Model::topPDisplay), + Map.entry("TOP_K", Model::topKDisplay), + Map.entry("MIN_P", Model::minPDisplay), + Map.entry("REASONING_EFFORT", Model::reasoningEffortArgument), + 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) { return this.argumentsToStringByArgs(this.appArguments.stream(), showAll); diff --git a/src/de/extio/lm_launcher/LaunchFrame.java b/src/de/extio/lm_launcher/LaunchFrame.java index 471bed6..0fd960b 100644 --- a/src/de/extio/lm_launcher/LaunchFrame.java +++ b/src/de/extio/lm_launcher/LaunchFrame.java @@ -695,16 +695,8 @@ public class LaunchFrame extends JFrame { } private void updateReasoningEffortVisibility() { - boolean selected = false; - for (int i = 0; i < this.appArgumentsTableModel.getRowCount(); i++) { - 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.lblReasoningEffort.setVisible(true); + this.comboReasoningEffort.setVisible(true); this.panel_3.revalidate(); this.panel_3.repaint(); } diff --git a/src/de/extio/lm_launcher/Model.java b/src/de/extio/lm_launcher/Model.java index de82197..052248b 100644 --- a/src/de/extio/lm_launcher/Model.java +++ b/src/de/extio/lm_launcher/Model.java @@ -50,6 +50,14 @@ record Model(String path, int contextSize, int maxContextSize, int gpuLayers, in 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) { for (final String effort : REASONING_EFFORTS) { if (effort.equals(value)) {