Scripted aider doesn't write to the .aider.chat.history.md and .aider.input.history files and does not honor .aiderignore
Issue
Hello,
I'm using the latest version of aider.
What should I put here to use claude sonnet or other models?
If I do model = Model('sonnet') as I do from the command line it will not work, it will say that lilellm cannot find the model.
When I run this script
from aider.coders import Coder
from aider.models import Model
model = Model('gpt-4-turbo')
coder = Coder.create(main_model=model, fnames=None, read_only_fnames=None, auto_commits=False, stream=False)
coder.run('/ls')
It returns lots of files which should be ignored according to .aiderignore and it doesn't modify the .aider.chat.history.md and .aider.input.history files in any way.
Is there anything else I need to do for getting the same behavior no matter if I run aider from the command line or in a scripted manner?
Version and model info
No response
Thank you for filing this issue.
This is a limitation when you script aider via Python as do not initialize whole script this way. A possible workaround is to script aider from the command line.
This document may be helpful -> https://aider.chat/docs/scripting.html#command-line
OK, I'll try to use pexpect to integrate aider.
Do you think aider works fine under pexpect?
No clue. But if I'd want to script aider, I'd either do it from a shell script or I'd start looking into aider's tests and guess from there what I'd call and how. E.g.
https://github.com/paul-gauthier/aider/blob/main/tests/basic/test_main.py
I'm going to close this issue for now, but feel free to add a comment here and I will re-open. Or feel free to file a new issue any time.