mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 17:55:01 +00:00
added scripting docs
This commit is contained in:
parent
1fe48fd161
commit
51425faff6
1 changed files with 46 additions and 0 deletions
46
docs/faq.md
46
docs/faq.md
|
@ -9,6 +9,7 @@
|
|||
- [Can I change the system prompts that aider uses?](#can-i-change-the-system-prompts-that-aider-uses)
|
||||
- [Can I run aider in Google Colab?](#can-i-run-aider-in-google-colab)
|
||||
- [How can I run aider locally from source code?](#how-can-i-run-aider-locally-from-source-code)
|
||||
- [Can I script aider?](#can-i-script-aider)
|
||||
|
||||
## How does aider use git?
|
||||
|
||||
|
@ -244,3 +245,48 @@ pip install -r requirements.txt
|
|||
# Run the local version of Aider:
|
||||
python -m aider.main
|
||||
```
|
||||
|
||||
# Can I script aider?
|
||||
|
||||
You can script aider via the command line or python.
|
||||
|
||||
## Command line
|
||||
|
||||
Aider takes a `--message` argument, where you can give it a natural language instruction.
|
||||
It will do that one thing, apply the edits to the files and then exit.
|
||||
So you could do:
|
||||
|
||||
```bash
|
||||
aider --message "make a script that prints hello" hello.js
|
||||
```
|
||||
|
||||
Or you can write simple shell scripts to apply the same instruction to many files:
|
||||
|
||||
```bash
|
||||
for FILE in *.py ; do
|
||||
aider --message "add descriptive docstrings to all the functions" $FILE
|
||||
done
|
||||
```
|
||||
|
||||
## Python
|
||||
|
||||
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']
|
||||
|
||||
# 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)
|
||||
|
||||
|
||||
# This will execute that one instruction on those files and then return
|
||||
coder.run(with_message=message)
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue