mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
Merge c925cb8ad0
into 3caab85931
This commit is contained in:
commit
1f8e76c953
3 changed files with 54 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,27 @@ 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 isinstance(args, str) and 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 is not currently set.")
|
||||||
|
else:
|
||||||
|
self.io.tool_output(f"Current thinking setting: {thinking_value}")
|
||||||
|
return
|
||||||
|
|
||||||
|
model.set_enable_thinking(args, self.io)
|
||||||
|
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"""
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ from typing import Optional, Union
|
||||||
import json5
|
import json5
|
||||||
import yaml
|
import yaml
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
from pydantic import TypeAdapter, ValidationError
|
||||||
|
|
||||||
from aider.dump import dump # noqa: F401
|
from aider.dump import dump # noqa: F401
|
||||||
from aider.llm import litellm
|
from aider.llm import litellm
|
||||||
|
@ -755,6 +756,19 @@ 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, io):
|
||||||
|
"""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"] = {}
|
||||||
|
try:
|
||||||
|
setting = TypeAdapter(bool).validate_python(setting)
|
||||||
|
self.extra_params["extra_body"].setdefault("template_vars", {}).update({"enable_thinking": setting})
|
||||||
|
except ValidationError:
|
||||||
|
io.tool_warning("Warning: the enable-thinking command expects true or false")
|
||||||
|
|
||||||
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 +878,17 @@ 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 "template_vars" in self.extra_params["extra_body"]
|
||||||
|
and "enable_thinking" in self.extra_params["extra_body"]["template_vars"]
|
||||||
|
):
|
||||||
|
return self.extra_params["extra_body"]["template_vars"]["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