langgraph-codegen PyPI package
Started on a UI for a Theory of Mind conversation analyzer. Came up with a nice UI using websim.ai, then started converting that to FastHTML.
The problem here is that the UI is very javascript heavy, and most of that isn’t necessary when it switches to FastHTML. But fixing that requires a lot of understanding of what was generated, and what the equivalent htmx version of that would look like.
So this web UI got running as a FastHTML site, so next step is to integrate in an agent. I had a few different designs, using a text DSL that shows nodes and edges. To use those, I needed to use the function that translate the DSL into python code. I’ve just been copying the file, but that was getting confusing, I wanted only one way to refer to it, so I put it on PyPI as langgraph-codegen and got that hooked up with github actions, so when I tag a new version it automatically moves to PyPI.
The main thing I want to do with it is to condense larger patterns into the DSL, and see what this does to the remaining code.
The thing I like about the code with the DSL is that both Nodes and Conditional Edges are represented by functions that take the Graph State as a parameter. The second thing I like about it is that Nodes have a single name, it’s in the text graph, and there’s a function with that name.
The langgraph graph building is way more flexible, but this DSL in many cases is simpler, easier to understand, and easier to implement.
The graph as a runnable is great, so for me it is simpler to think of the runnable as a graph designed with nodes and edges being functions that take the Graph State as a parameter. So to ‘redesign’ the graph could be adding a few function names to the graph design, and writing those functions. That’s how I want to experiment with langgraph, so I use this DSL to help with that approach.