Aider-AI / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
20.95k stars 1.94k forks source link

How to use Aider from python code? #1017

Closed CK-Daniel closed 2 months ago

CK-Daniel commented 2 months ago

Issue

Question: Is it possible to user Aider from inside python? I want to add some personal user interface and some personal function to Aider, Can I call and init Aider from the code itself?

Version and model info

No response

paul-gauthier commented 2 months ago

Thanks for trying aider and filing this issue. This doc may be helpful:

https://aider.chat/docs/scripting.html

CK-Daniel commented 2 months ago

Thanks for trying aider and filing this issue. This doc may be helpful:

https://aider.chat/docs/scripting.html

Thank you! Could you please provide quick example of how to set up the anthropic models in the python section?

PiProjectsUS commented 2 months ago
from aider.coders import Coder
from aider.models import Model
from aider.io import InputOutput
io = InputOutput(yes=True)
model = Model("claude-3-5-sonnet-20240620")
coder = Coder.create(main_model=model, io=io)
aider_output = coder.run("instructions")
paul-gauthier commented 2 months ago

I'm going to close this issue for now, but feel free to add a comment here and I will re-open or file a new issue any time.

peter-mw commented 2 days ago

@paul-gauthier how to solve error ?

ModuleNotFoundError: No module named 'aider.coders'; 'aider' is not a package