Tool calling in LangGraph and how to update the Graph-State with Tools output #1616
-
Hey,
And I have a very simple tool which is called when the user provides his name in the query, to find the date_of_birth in the database.
How am I now able to update the GraphState in a way that date_of_birth is set in the State? The tool node is returning {"messages": output} which will update the state. But what if I want to return "date_of_birth"? Is there an easy way to solve this dynamically or is there even a better way? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
The prebuilt def custom_tool_node(state):
return {"date_of_birth": find_user_date_of_birth(state['first_name']+state['last_name'])} This node will update the "date_of_birth" key. You may also wish to append the ToolMessage to the list of messages, so be careful of that as well. Let me know if this helps! |
Beta Was this translation helpful? Give feedback.
-
Hi folks! We have now added support for updating the state from the tools using the new Command type. Please see this how-to guide for reference https://langchain-ai.github.io/langgraph/how-tos/update-state-from-tools/. Let me know if you have any questions / feedback |
Beta Was this translation helpful? Give feedback.
Hi folks! We have now added support for updating the state from the tools using the new Command type. Please see this how-to guide for reference https://langchain-ai.github.io/langgraph/how-tos/update-state-from-tools/. Let me know if you have any questions / feedback