diff --git a/aider/models.py b/aider/models.py index cf20dee36..fdbb2d152 100644 --- a/aider/models.py +++ b/aider/models.py @@ -47,7 +47,7 @@ class Model: return if self.is_gpt35(): - self.edit_format = "whole-func" + self.edit_format = "whole" self.always_available = True if tokens == 4: diff --git a/scripts/benchmark.py b/scripts/benchmark.py index 8a8da71b0..7a0fe526b 100644 --- a/scripts/benchmark.py +++ b/scripts/benchmark.py @@ -1,9 +1,17 @@ import os import shutil import sys -from tempfile import TemporaryDirectory +from pathlib import Path -from git import Repo +from aider import models +from aider.coders import Coder +from aider.dump import dump # noqa: F401 +from aider.io import InputOutput + +# from git import Repo + + +# from tempfile import TemporaryDirectory def create_temp_repo(dirname, tempdir): @@ -14,22 +22,30 @@ def create_temp_repo(dirname, tempdir): if os.path.isfile(s): shutil.copy2(s, d) + add_files = [] + for root, _, files in os.walk(tempdir): + for file in files: + if "test" not in file: + rel_path = os.path.relpath(os.path.join(root, file), tempdir) + add_files.append(rel_path) + + """ + # Create a new git repo in tempdir + repo = Repo.init(tempdir) + + for rel_path in add_files: + repo.git.add(rel_path) + + # Commit with message "initial" + repo.git.commit(m="initial") + """ + # Copy .docs subdir to tempdir as 'docs' docs_src = os.path.join(dirname, ".docs") docs_dst = os.path.join(tempdir, "docs") shutil.copytree(docs_src, docs_dst, False, None) - # Create a new git repo in tempdir - repo = Repo.init(tempdir) - - # Add all copied files to the repo, excluding those with 'test' in the filename - for root, _, files in os.walk(tempdir): - for file in files: - if "test" not in file: - repo.git.add(os.path.relpath(os.path.join(root, file), tempdir)) - - # Commit with message "initial" - repo.git.commit(m="initial") + return add_files def main(tempdir): @@ -39,7 +55,28 @@ def main(tempdir): dirname = sys.argv[1] - create_temp_repo(dirname, tempdir) + fnames = create_temp_repo(dirname, tempdir) + tempdir = Path(tempdir) + fnames = [tempdir / fn for fn in fnames] + + io = InputOutput( + pretty=True, + yes=False, + ) + + main_model = models.Model("gpt-3.5-turbo") + + coder = Coder.create( + main_model, + None, + io, + os.environ["OPENAI_API_KEY"], + fnames=fnames, + verbose=True, + git=False, + ) + + coder.run(with_message="follow the instructions in the .md file") if __name__ == "__main__":