Replies: 5 comments 1 reply
-
its really needed any leads |
Beta Was this translation helpful? Give feedback.
-
So, this is really an open problem... What can be done currently? Treat it like a LinkedList of sorts? just skip the node? Or make the graph from scratch without the node? |
Beta Was this translation helpful? Give feedback.
-
Yes, this would be a great feature. I'll need this in an upcoming project. @karthikcs did you have any luck finding a solution? |
Beta Was this translation helpful? Give feedback.
-
@karthikcs @MacAttak @akash97715 TL;DRLogic to remove the edge. It's internally stored as a set so you can simply run the print(graph.builder.edges)
# edges sorted as set internally
# {('generate_structured_response', '__end__'), ('tools', 'agent'), ('__start__', 'agent')}
graph.builder.edges.remove((from, to)) # where from and to are the node names Original Complied GraphModified Graph (before delete)I'm adding a modified_agent = agent.builder
modified_agent = modified_agent.add_node("new_node", func)
modified_agent = modified_agent.add_edge("generate_structured_response", "new_node") Important Both the Modified Graph (after delete)modified_agent = agent.builder
modified_agent = modified_agent.add_node("new_node", func)
modified_agent = modified_agent.add_edge("generate_structured_response", "new_node")
# logic to remove the edge. It's internally sorted as a set so you can simply run the `remove` method to knock it off.
modified_agent.edges.remove(("generate_structured_response", "__end__"))
new_math_agent = new_math_agent.add_edge("new_node", "__end__")
agent.compile(name="agent") |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am working on a project based on Langgraph. I did not see an option to delete a node and/or an edge from an existing graph. I think we should have for complex projects where we need to serialize the graph and edit in the future
Beta Was this translation helpful? Give feedback.
All reactions