aider icon indicating copy to clipboard operation
aider copied to clipboard

Jupyter notebooks and aider

Open lockmeister opened this issue 1 year ago • 1 comments

When working with Jupyter notebooks, this problem occurs:

The SEARCH section must exactly match an existing block of lines including all white space, comments, indentation, docstrings, etc

I'm using nbstripout and nbdime but aider still has problems matching the text.

Aider version: 0.56.0 Python version: 3.10.12 Platform: Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.35 Python implementation: CPython Virtual environment: Yes OS: Linux 5.15.153.1-microsoft-standard-WSL2 (64bit) Git version: git version 2.34.1

Aider v0.56.0 Main model: openrouter/anthropic/claude-3.5-sonnet with diff edit format, prompt cache, infinite output Weak model: openrouter/anthropic/claude-3-haiku-20240307 Git repo: .git with 30 files Repo-map: using 1024 tokens, files refresh Added plotter.ipynb to the chat. Added portfolio_backtester.py to the chat. Restored previous conversation history.

lockmeister avatar Sep 17 '24 00:09 lockmeister

Thanks for trying aider and filing this issue.

LLMs have trouble editing jupiter notebooks because they are python code wrapped in json. It's a complex format.

You could try --edit-format whole, but that will be quite slow.

paul-gauthier avatar Sep 20 '24 19:09 paul-gauthier

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.

paul-gauthier avatar Oct 07 '24 20:10 paul-gauthier

I would assume that one could create a wrapper around jupyter notebooks that presents the code to the model by extracting the "source" attribute from the "code" cell_type and still inherently keeps track of which code line is in which jupyter block. Then, when the model then changes some lines maps the changes back to the jupyter block.

I would be happy to help implementing it, however, I think it would be more efficient if someone with experience of the Aider Framework joins in. For me it would be helpful to have a chat about how the model interacts with the code, because then I don't need to learn the Aider codebase to implement the feature. So if someone is interested, write me.

Znerual avatar Jan 09 '25 11:01 Znerual