The key attributes that correspond to the tool's schema:
The key methods to execute the function associated with the tool:
@tool decoratorWay to create tools is using the @tool decorator.
from langchain_core.tools import tool
@tool
def multiply(a: int, b: int) -> int:
"""Multiply two numbers."""
return a * b
Once you have defined a tool, you can use it directly by calling the function.
multiply.invoke({"a": 2, "b": 3})
You can also inspect the tool's schema and other properties:
print(multiply.name) # multiply
print(multiply.description) # Multiply two numbers.
print(multiply.args)
# {
# 'type': 'object',
# 'properties': {'a': {'type': 'integer'}, 'b': {'type': 'integer'}},
# 'required': ['a', 'b']
# }