artem

artem

LLM with Livebook - any tips or workflows you recommend?

Hi All

I use AI with my elixir coding pretty successfully. Maybe it tells more about my elixir skills level, but I manage to get quite a lot of use from Cursor Composer agent mode which suggests changes to files and I can accept/reject with a click. And I can add hex docs of needed libraries to it, so it’s aware of APIs needed!

My current project is an RnD in Livebook and.. I fail to figure out a good workflow for livebooks. Just editing running livebooks’s markdown file doesn’t work as it local changes will not be loaded and even more, any changes done in livebook UI will overwrite the file.

Good workflow
The best I was able to figure so far is to just chat with my livebook content in Cursor Composer and copy-paste content from chat to livebook and back. It works, but it tedious.

What do you use for AI in livebook?

  • Same copy-paste between chats approach?
  • Or is there an [easy] way to ask livebook session refresh itself from file instead of autosaving to file somehow?
  • Or is there some agent tool able to edit livebook content in browser?
  • Something else?

Marked As Solved

Also Liked

artem

artem

The process for setting it up was a bit tough (e.g. I had to switch from Livebook desktop to versioned livebooks installed to asdf internals) and I had to learn how mcp servers work, but in the end it was a very good solution. Thanks, @nulltree !

artem

artem

Self-answering of what worked for me okayish so far.

Tool I use
First of all Cursor Composer Agent is good and helps (with my level of elixir skills). Indeed it is not too knowledgeable on elixir idioms, so you may need to ask it to pay more attention to elixir idiomacy (e.g. more pattern matching, less branhing) + add some documentation on the libraries you use (e.g. to its list of docs you can just add links to hexdocs of Kinio, Tesla, etc). Sure it also sometimes makes stupid mistakes, but if I look after it, then it helps me code quite significantly. Except for this issue with LiveView ignoring and overwriting the underlying files.

So here’s what I used with some success:

Option for short notebooks: Just copy-pasting
You ask for Cursor agent suggestions, but do not apply to a file. Just copy-paste them to livebook editor manually. With small livebook notebooks it actually worked surprisingly well and wasn;t too annoying.

Option for large notebooks: Agent to edit file and then reconnect
Then my notebook grew from “just a small exploration” into "let’s make an externally accessible API out of it. Still RnD, but with some thinking of proper error handling, several secrets, Livebook Teams deployment, etc) and copy-pasting across many cells became painful. I figured the following process:

  1. Type next prompt to Cursor, discuss with it whatever you want. You notebook can be running meanwhile: As long as you type nothing in the livebook UI it doesn’t seem to overwrite the underlying file
  2. Close the session via notebook’s top of page button. It takes you to the Livebook home page
  3. Click open and notebook you just worked on will be on top of the Recent ones, so quick open
  4. From address bar copy session ID (that I’ll need in the end to send HTTP request)
  5. In sidebar open secrets (keyboard shortcut “ss”) and enable whichever secrets you need
  6. In sibebar open outline (keyboard shortcut “so”) click on the final section (or whichever section starts what you need to test and evaluate it"
  7. Eventually in postman (or whichever tool you use for sending http requests) replace old session id with the one copied on step 4 and you can send requests

It looks like a lot of things to do and I am not super-happy with the process indeed. However, once I did it several times it got to muscle memory and I am relatively fast with it - faster and more accurate than with copy-pasting indeed.

Any other options?
Does anybody have a better idea? After all what I am essentially doing it just close-recreate session for the same file (and reenable same secrets). Is there possibly some way e.g. to send message from IEex console to do it all in one go?

artem

artem

Wow, if it works, that seems to be exactly what I was hoping for! Thanks, Leon, I’ll give it a try!

Last Post!

artem

artem

  1. Reloading livebook on making changes to file
    This worked very well for me, just as you’d expect: you (or AI) changed something in the standalone editor and livebook’s reloaded.
    But then it stopped (I think after I started using different livebook versions or something like this). Now it throws some storage-related errors whenever tried reloading sessions. Quick research didn’t help and as my LiveBook-related task was about to finish, I didn’t have motivation to dig deeper or report a bug. Maybe will try again when working with LiveBook much next time.

  2. MCP tool for AI to read results of cells
    Didn’t find it particularly useful, but I experimented with it just a little bit. I had many cells and IMHO cursor was getting lost in where to look for the results in.

  3. Misc
    Cursor (on Claude Sonnet 3.5 mainly) was all the time getting lost with 3 VS 4 backtick formatting in livebook notebooks. That was giving headaches with manual fixing. Could be solved by better prompting probably.

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36654 110
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44532 311
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement