mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00
Simplify scripting aider
This commit is contained in:
parent
51425faff6
commit
87ab5495a7
2 changed files with 11 additions and 10 deletions
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue