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

Interface LangChain tools must implement.

tools.base.BaseToolkit

Base Toolkit representing a collection of related tools.

tools.base.InjectedToolArg()

Annotation for a Tool arg that is not meant to be generated by a model.

tools.base.SchemaAnnotationError

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

tools.base.ToolException

Optional exception that tool throws when 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.convert.convert_runnable_to_tool(runnable)

Convert a Runnable into a BaseTool.

tools.convert.tool(*args[,ย return_direct,ย ...])

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.