tools#

Tools are classes that an Agent uses to interact with the world.

Each tool has a description. Agent uses the description to choose the right tool for the job.

Class hierarchy:

RunnableSerializable --> BaseTool --> <name>Tool  # Examples: AIPluginTool, BaseGraphQLTool
                                      <name>      # Examples: BraveSearch, HumanInputRun

Main helpers:

CallbackManagerForToolRun, AsyncCallbackManagerForToolRun

Classes

tools.base.BaseTool

Base class for all LangChain tools.

tools.base.BaseToolkit

Base class for toolkits containing related tools.

tools.base.InjectedToolArg()

Annotation for tool arguments that are injected at runtime.

tools.base.InjectedToolCallId()

Annotation for injecting the tool call ID.

tools.base.SchemaAnnotationError

Raised when args_schema is missing or has an incorrect type annotation.

tools.base.ToolException

Exception thrown when a tool execution error occurs.

tools.retriever.RetrieverInput

Input to the retriever.

tools.simple.Tool

Tool that takes in function or coroutine directly.

tools.structured.StructuredTool

Tool that can operate on any number of inputs.

Functions

tools.base.create_schema_from_function(...)

Create a pydantic schema from a function's signature.

tools.base.get_all_basemodel_annotations(cls, *)

Get all annotations from a Pydantic BaseModel and its parents.

tools.convert.convert_runnable_to_tool(runnable)

Convert a Runnable into a BaseTool.

tools.convert.tool()

Make tools out of functions, can be used with or without arguments.

tools.render.render_text_description(tools)

Render the tool name and description in plain text.

tools.render.render_text_description_and_args(tools)

Render the tool name, description, and args in plain text.

tools.retriever.create_retriever_tool(...[, ...])

Create a tool to do retrieval of documents.