is it possible to update state in condition function? #2113
-
Can I update the state in the condition/path function of graph.add_conditional_edges?
I have tried but its not working. If it doesn't work, how do I make it work? One option for me is to write a new node to process the state but it will increase redundancy. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi Anmol, I don't think you can unfortunately, and it would mix up the concept of nodes and edges. Would it be possible instead to
You won't have to write a new node as the existing nodes can update more than 1 piece of state (can add more than 1 key value pair in the return dict of the node). def node_a(state):
response = llm.invoke(state['messages'])
return {"messages": [response], "variable":"UPDATED"} #update state['variable'] in existing node |
Beta Was this translation helpful? Give feedback.
Hi Anmol, I don't think you can unfortunately, and it would mix up the concept of nodes and edges.
Would it be possible instead to
You won't have to write a new node as the existing nodes can update more than 1 piece of state (can add more than 1 key value pair in the return dict of the node).