Tools are custom functions that enhance the agent's functionality. They should be decorated with @tool.
Set Up
from crypto_com_agent_client import tool
Example Tools
Weather Tool
This tool retrieves the current weather for a given location.
@tool
def get_weather(location: str) -> str:
"""
Provide the current weather for a given location.
Args:
location (str): The name of the location for which to retrieve weather information.
Returns:
str: A message describing the weather in the specified location.
"""
return f"The weather in {location} is sunny."
Custom Greeting Tool
This tool generates a personalized greeting message for a user.
@tool
def greet_user(name: str) -> str:
"""
Generate a personalized greeting message.
Args:
name (str): The name of the user to greet.
Returns:
str: A greeting message addressed to the user.
"""
return f"Hello, {name}! How can I assist you today?"
Arithmetic Tool
This tool calculates the sum of two integers.
@tool
def calculate_sum(a: int, b: int) -> int:
"""
Calculate the sum of two integers.
Args:
a (int): The first number to add.
b (int): The second number to add.
Returns:
int: The sum of the two numbers.
"""
return a + b
Using Tools in the Agent
To use the tools in your agent, initialize it with the required configurations: