mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +00:00
SwitchModel -> SwitchCoder
This commit is contained in:
parent
4537e6c16a
commit
f440479c48
2 changed files with 14 additions and 7 deletions
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue