ToolNode has been moved to langchain package.
Update your import to import { ToolNode } from "langchain";
A node that runs the tools requested in the last AIMessage. It can be used
either in StateGraph with a "messages" key or in MessageGraph. If multiple
tool calls are requested, they will be run in parallel. The output will be
a list of ToolMessages, one for each tool call.
constgetWeather = tool((input) => { if (["sf", "san francisco"].includes(input.location.toLowerCase())) { return"It's 60 degrees and foggy."; } else { return"It's 90 degrees and sunny."; } }, { name:"get_weather", description:"Call to get the current weather.", schema:z.object({ location:z.string().describe("Location to get the weather for."), }), });
constgetWeather = tool((input) => { if (["sf", "san francisco"].includes(input.location.toLowerCase())) { return"It's 60 degrees and foggy."; } else { return"It's 90 degrees and sunny."; } }, { name:"get_weather", description:"Call to get the current weather.", schema:z.object({ location:z.string().describe("Location to get the weather for."), }), });
Deprecated
ToolNode
has been moved to langchain package. Update your import toimport { ToolNode } from "langchain";
A node that runs the tools requested in the last AIMessage. It can be used either in StateGraph with a "messages" key or in MessageGraph. If multiple tool calls are requested, they will be run in parallel. The output will be a list of ToolMessages, one for each tool call.
Example
Example