From 87ab5495a76d4989a3cc0ca8d87f713b0c7f8841 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 3 Nov 2023 14:29:45 -0700 Subject: [PATCH] Simplify scripting aider --- aider/coders/base_coder.py | 12 ++++++++---- docs/faq.md | 9 +++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 5ee4dfa72..57de58f45 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -19,6 +19,7 @@ from rich.markdown import Markdown from aider import models, prompts, utils from aider.commands import Commands from aider.history import ChatSummary +from aider.io import InputOutput from aider.repo import GitRepo from aider.repomap import RepoMap from aider.sendchat import send_with_retries @@ -52,16 +53,16 @@ class Coder: @classmethod def create( self, - main_model, - edit_format, - io, + main_model=None, + edit_format=None, + io=None, skip_model_availabily_check=False, **kwargs, ): from . import EditBlockCoder, WholeFileCoder if not main_model: - main_model = models.GPT35_16k + main_model = models.GPT4 if not skip_model_availabily_check and not main_model.always_available: if not check_model_availability(io, main_model): @@ -105,6 +106,9 @@ class Coder: if not fnames: fnames = [] + if io is None: + io = InputOutput() + self.chat_completion_call_hashes = [] self.chat_completion_response_hashes = [] self.need_commit_before_edits = set() diff --git a/docs/faq.md b/docs/faq.md index 20d41f02b..f517d8a78 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -273,9 +273,7 @@ done You can also script aider from python: ```python -from aider.io import InputOutput from aider.coders import Coder -from aider.models import GPT4 # This is a list of files to add to the chat fnames = ['foo.py'] @@ -283,10 +281,9 @@ fnames = ['foo.py'] # This is the instruction to give to GPT message = 'make a script that prints hello world!' -io = InputOutput() -coder = Coder.create(GPT4, None, io, fnames=fnames) - +# Create a coder object +coder = Coder.create(fnames=fnames) # This will execute that one instruction on those files and then return -coder.run(with_message=message) +coder.run(message) ```