Tool calling

AIMessage
object, which includes a tool_calls
field that specifies the tool name and input arguments:
Prebuilt tools
LangChain provides prebuilt tool integrations for common external systems including APIs, databases, file systems, and web data. Browse the integrations directory for available tools. Common categories:- Search: Bing, SerpAPI, Tavily
- Code execution: Python REPL, Node.js REPL
- Databases: SQL, MongoDB, Redis
- Web data: Scraping and browsing
- APIs: OpenWeatherMap, NewsAPI, etc.
Custom tools
You can define custom tools using thetool
function. For example:
Tool execution
While the model determines when to call a tool, execution of the tool call must be handled by a runtime component. LangGraph provides prebuilt components for this:- ToolNode: A prebuilt node that executes tools.
createReactAgent
: Constructs a full agent that manages tool calling automatically.