Tools

Contents

Tools#

Tools allows LLM to interact with the environment. Tooling is probably is the most important feature of the framework.

Defining#

Tools implement how LLMs can interact with external systems. In Lang Chain, tools can take various forms, which are described in the Tool interface section.

Check full guide in Tools.


The most common way to define the tools is to use the @tool decorator. According to Lang Chain, the tool wrapped object gets all properties of the “tool interaface”.

The following cell defines the tool.

from langchain_core.tools import tool

@tool
def my_tool(a: int, b: str) -> float:
    """This is my tool"""
    return 4.20

The important attributes for Langchain’s internal processes are presented below.

my_tool.name
'my_tool'
my_tool.description
'This is my tool'
my_tool.args
{'a': {'title': 'A', 'type': 'integer'}, 'b': {'title': 'B', 'type': 'string'}}