From f440479c486620348151488feb9fd2964cbafbcc Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 28 Jul 2024 17:49:02 -0300 Subject: [PATCH] SwitchModel -> SwitchCoder --- aider/commands.py | 10 ++++++---- aider/main.py | 11 ++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index d014db6b2..c05138632 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -15,7 +15,7 @@ from aider.utils import is_image_file from .dump import dump # noqa: F401 -class SwitchModel(Exception): +class SwitchCoder(Exception): def __init__(self, model=None, edit_format=None): self.model = model self.edit_format = edit_format @@ -43,7 +43,7 @@ class Commands: model_name = args.strip() model = models.Model(model_name) models.sanity_check_models(self.io, model) - raise SwitchModel(model=model) + raise SwitchCoder(model=model) def cmd_mode(self, args): "Switch to a new editing mode" @@ -52,10 +52,12 @@ class Commands: valid_formats = "diff udiff whole".split() if ef not in valid_formats: - self.io.tool_error(f"Invalid edit format: {ef}. Valid formats are: {', '.join(valid_formats)}") + self.io.tool_error( + f"Invalid edit format: {ef}. Valid formats are: {', '.join(valid_formats)}" + ) return - raise SwitchModel(edit_format=ef) + raise SwitchCoder(edit_format=ef) def completions_model(self): models = litellm.model_cost.keys() diff --git a/aider/main.py b/aider/main.py index ea1c622f8..6e06c8d69 100644 --- a/aider/main.py +++ b/aider/main.py @@ -12,7 +12,7 @@ from prompt_toolkit.enums import EditingMode from aider import __version__, models, utils from aider.args import get_parser from aider.coders import Coder -from aider.commands import SwitchModel +from aider.commands import SwitchCoder from aider.io import InputOutput from aider.llm import litellm # noqa: F401; properly init litellm on launch from aider.repo import GitRepo @@ -587,8 +587,13 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F try: coder.run() return - except SwitchModel as switch: - coder = Coder.create(main_model=switch.model, io=io, from_coder=coder) + except SwitchCoder as switch: + coder = Coder.create( + main_model=switch.model, + edit_format=switch.edit_format, + io=io, + from_coder=coder, + ) coder.show_announcements()