-
Notifications
You must be signed in to change notification settings - Fork 802
Description
Description
I want to be able to manipulate the contents of another code cell programatically through python.
Think of LLM enabled widgets generally or a Buckaroo use case specifically.
Buckaroo has a low code UI that allows users to run common commands through a UI, the set of executed commands are called operations. There is also an auto-cleaning function which adds operations to the UI. Operations can also be emitted as python code.
The current UI lets users copy and paste this generated code. It would be a much better experience if the generated code was added to a cell below the widget. In this use case, the code is added to a function, so the next cell wouldn't be reactive unless that function was called in another cell.
Suggested solution
I would like an api, that allows a user to
- Determine which cell the current anywidget based widget is executing from
- Insert a cell into the app, relative to another cell or in absolute order
- retrieve the code contents of a cell
- modify the code contents of a cell
- Delete and execute would round out this API but are not necessary for my application
Alternative
This isn't obviously possible in jupyter either. To make something like this in jupyter work, I'm fairly sure I would have to use javascript APIs that are brittle.
One problem with this system is making sure you get a handle on the correct cell.
For the cell I'm trying to control, I could inject a UUID comment that makes is very clear I'm manipulating the correct cell. Generally though, this is metadata about a cell. an API for that could be useful too.
I understand that this breaks "just a regular python script" assumptions about marimo. I want to use APIs like this for interactive use cases.