|
|
|
|
|
by TimPC
448 days ago
|
|
One thing that's nice in LangGraph is the flexibility in what a node is. A node doesn't have to be an agent it can be any State manipulation function. So you can create nodes that exclusively do preprocessing or postprocessing and get your run loop as close as possible to just ainvoke on your graph repeatedly. You can have a subclass of your Node class be an AgentNode class and then subclass that for each type of Agent and then when you declare your Graph object you pass in the data to instantiate the AgentNode with the type of data it needs. It is a bit weird that LangGraph doesn't have a default Node class but it sort of makes sense that they want you to write it in a way that makes sense for how you use it. I do highly recommend abstracting your graph into Node and Edge classes (with appropriate subclasses) and being able to declare your graph in a constant that you can pass to a build_graph method. Getting as much code reuse as possible dramatically simplifies debugging graph issuses. |
|