mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +00:00
wip
This commit is contained in:
parent
1b41bbd0d9
commit
d9b356de99
2 changed files with 52 additions and 15 deletions
|
@ -47,7 +47,7 @@ class Model:
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.is_gpt35():
|
if self.is_gpt35():
|
||||||
self.edit_format = "whole-func"
|
self.edit_format = "whole"
|
||||||
self.always_available = True
|
self.always_available = True
|
||||||
|
|
||||||
if tokens == 4:
|
if tokens == 4:
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
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):
|
def create_temp_repo(dirname, tempdir):
|
||||||
|
@ -14,22 +22,30 @@ def create_temp_repo(dirname, tempdir):
|
||||||
if os.path.isfile(s):
|
if os.path.isfile(s):
|
||||||
shutil.copy2(s, d)
|
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'
|
# Copy .docs subdir to tempdir as 'docs'
|
||||||
docs_src = os.path.join(dirname, ".docs")
|
docs_src = os.path.join(dirname, ".docs")
|
||||||
docs_dst = os.path.join(tempdir, "docs")
|
docs_dst = os.path.join(tempdir, "docs")
|
||||||
shutil.copytree(docs_src, docs_dst, False, None)
|
shutil.copytree(docs_src, docs_dst, False, None)
|
||||||
|
|
||||||
# Create a new git repo in tempdir
|
return add_files
|
||||||
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")
|
|
||||||
|
|
||||||
|
|
||||||
def main(tempdir):
|
def main(tempdir):
|
||||||
|
@ -39,7 +55,28 @@ def main(tempdir):
|
||||||
|
|
||||||
dirname = sys.argv[1]
|
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__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue