mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-06 04:35:00 +00:00
feat: cmd_enable_thinking
Adds a command which can be used to enable or disable reasoning by supported models (Qwen3). This is more robust than using the /no_think prompt and saves a small number of tokens.
This commit is contained in:
parent
56b45ce1d3
commit
8010bebb6b
3 changed files with 49 additions and 0 deletions
|
@ -145,6 +145,14 @@ def get_parser(default_config_files, git_root):
|
||||||
type=str,
|
type=str,
|
||||||
help="Set the thinking token budget for models that support it (default: not set)",
|
help="Set the thinking token budget for models that support it (default: not set)",
|
||||||
)
|
)
|
||||||
|
group.add_argument(
|
||||||
|
"--enable-thinking",
|
||||||
|
type=str,
|
||||||
|
help=(
|
||||||
|
"Switches between thinking and non-thinking modes for models that support it."
|
||||||
|
" (default: not set)"
|
||||||
|
),
|
||||||
|
)
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"--verify-ssl",
|
"--verify-ssl",
|
||||||
action=argparse.BooleanOptionalAction,
|
action=argparse.BooleanOptionalAction,
|
||||||
|
|
|
@ -1588,6 +1588,28 @@ class Commands:
|
||||||
announcements = "\n".join(self.coder.get_announcements())
|
announcements = "\n".join(self.coder.get_announcements())
|
||||||
self.io.tool_output(announcements)
|
self.io.tool_output(announcements)
|
||||||
|
|
||||||
|
def cmd_enable_thinking(self, args):
|
||||||
|
"""Enable or disable thinking for models that support it."""
|
||||||
|
model = self.coder.main_model
|
||||||
|
if not args.strip():
|
||||||
|
# Display current value if no args are provided
|
||||||
|
thinking_value = model.get_enable_thinking()
|
||||||
|
if thinking_value is None:
|
||||||
|
self.io.tool_output("thinking effort is not currently set.")
|
||||||
|
else:
|
||||||
|
self.io.tool_output(f"Current thinking setting: {thinking_value}")
|
||||||
|
return
|
||||||
|
|
||||||
|
value = args.strip()
|
||||||
|
model.set_enable_thinking(value)
|
||||||
|
thinking_value = model.get_enable_thinking()
|
||||||
|
self.io.tool_output(f"Set enable thinking to {thinking_value}")
|
||||||
|
self.io.tool_output()
|
||||||
|
|
||||||
|
# Output announcements
|
||||||
|
announcements = "\n".join(self.coder.get_announcements())
|
||||||
|
self.io.tool_output(announcements)
|
||||||
|
|
||||||
def cmd_copy_context(self, args=None):
|
def cmd_copy_context(self, args=None):
|
||||||
"""Copy the current chat context as markdown, suitable to paste into a web UI"""
|
"""Copy the current chat context as markdown, suitable to paste into a web UI"""
|
||||||
|
|
||||||
|
|
|
@ -755,6 +755,15 @@ class Model(ModelSettings):
|
||||||
self.extra_params["extra_body"] = {}
|
self.extra_params["extra_body"] = {}
|
||||||
self.extra_params["extra_body"]["reasoning_effort"] = effort
|
self.extra_params["extra_body"]["reasoning_effort"] = effort
|
||||||
|
|
||||||
|
def set_enable_thinking(self, setting):
|
||||||
|
"""Set the enable thinking parameter for models that support it"""
|
||||||
|
if setting is not None:
|
||||||
|
if not self.extra_params:
|
||||||
|
self.extra_params = {}
|
||||||
|
if "extra_body" not in self.extra_params:
|
||||||
|
self.extra_params["extra_body"] = {}
|
||||||
|
self.extra_params["extra_body"]["enable_thinking"] = setting
|
||||||
|
|
||||||
def parse_token_value(self, value):
|
def parse_token_value(self, value):
|
||||||
"""
|
"""
|
||||||
Parse a token value string into an integer.
|
Parse a token value string into an integer.
|
||||||
|
@ -864,6 +873,16 @@ class Model(ModelSettings):
|
||||||
return self.extra_params["extra_body"]["reasoning_effort"]
|
return self.extra_params["extra_body"]["reasoning_effort"]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_enable_thinking(self):
|
||||||
|
"""Get enable thinking value if available"""
|
||||||
|
if (
|
||||||
|
self.extra_params
|
||||||
|
and "extra_body" in self.extra_params
|
||||||
|
and "enable_thinking" in self.extra_params["extra_body"]
|
||||||
|
):
|
||||||
|
return self.extra_params["extra_body"]["enable_thinking"]
|
||||||
|
return None
|
||||||
|
|
||||||
def is_deepseek_r1(self):
|
def is_deepseek_r1(self):
|
||||||
name = self.name.lower()
|
name = self.name.lower()
|
||||||
if "deepseek" not in name:
|
if "deepseek" not in name:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue