from praisonaiagents import Agent, BaseTool, tool
# Method 1: Using @tool decorator
@tool
def get_weather(city: str) -> str:
"""Get current weather for a city."""
return f"Weather in {city}: Sunny, 22°C"
# Method 2: Subclassing BaseTool
class StockPriceTool(BaseTool):
name = "get_stock_price"
description = "Get current stock price for a symbol"
def run(self, symbol: str) -> dict:
return {"symbol": symbol, "price": 150.00}
# Use with agent
agent = Agent(
name="Assistant",
tools=[get_weather, StockPriceTool()]
)