Tool calling in LangGraph and how to update the Graph-State with Tools output #1616
Unanswered
dominik-roemer
asked this question in
Q&A
Replies: 1 comment 1 reply
-
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.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey,
atm I'm looking into LangGraph and the agents ability to call tools. I was able to build an agent which has this architecture. The idea is taken from: https://langchain-ai.github.io/langgraph/tutorials/introduction/#part-2-enhancing-the-chatbot-with-tools
When a tool is called the Chatbot receives a Toolmesage with the output of the tool. Now my question is, how to take this output and write it into the state. Let's say my state looks something like this:
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.
All reactions