Tools allow AI agents to interact with the world and perform specific actions. Think of tools as the “hands” of your agent that let it accomplish tasks beyond just generating text.
These tools help agents access information beyond their training data.Examples:
Web search tools
Database query tools
Document retrieval tools
Copy
# Example of a simple web search toolfrom praisonaiagents import Agentdef web_search(query): # Simplified example return f"Results for: {query}"agent = Agent( instructions="Research assistant", tools=[web_search])
Here’s a simple example of creating and using tools in PraisonAI:
Copy
from praisonaiagents import Agent# Define a simple calculator tooldef calculator(expression): try: return str(eval(expression)) except: return "Error: Could not calculate"# Create an agent with the toolmath_agent = Agent( instructions="You are a math tutor helping students solve problems", tools=[calculator])# Use the agentmath_agent.start("Calculate 24 * 17 and explain the steps")