Defining tools
So far, we have defined tools as OpenAPI schemas. But to run the workflow end to end, LangGraph should be able to call tools itself during the execution. Hence, in this section, let’s discuss how we define tools as Python functions or callables.
A LangChain tool has three essential components:
Name
: A unique identifier for the toolDescription
: Text that helps the LLM understand when and how to use the toolPayload schema
: A structured definition of the inputs the tool accepts
It allows an LLM to decide when and how to call a tool. Another important distinction of a LangChain tool is that it can be executed by an orchestrator, such as LangGraph. The base interface for a tool is BaseTool
, which inherits from a RunnableSerializable
itself. That means it can be invoked or batched as any Runnable
, or serialized or deserialized as any Serializable
.
Built-in LangChain tools
LangChain has many tools already available across various...