from upsonic import Agent, Task
from upsonic.tools import tool
@tool
def search_market_data(query: str) -> str:
"""Search for market data and trends."""
return f"Market data for {query}: Upward trend, 15% YoY growth"
@tool
def analyze_competitors(company: str) -> str:
"""Analyze competitive landscape."""
return f"Competitors of {company}: Strong market position, 35% market share"
@tool
def get_financial_metrics(symbol: str) -> str:
"""Get key financial metrics."""
return f"Financials for {symbol}: P/E 28, Revenue $394B, Profit margin 25%"
# Agent with reasoning enabled
agent = Agent(
model="openai/gpt-4o",
name="AnalysisAgent",
tools=[search_market_data, analyze_competitors, get_financial_metrics],
enable_thinking_tool=True,
enable_reasoning_tool=True
)
# Simple lookup - disable reasoning for speed
simple_task = Task(
description="Get the current market data for MSFT",
enable_thinking_tool=False,
enable_reasoning_tool=False # Single tool, no analysis needed
)
result1 = agent.do(simple_task)
print("Simple task result:", result1)
# Complex analysis - use full reasoning
complex_task = Task(
description="Evaluate if GOOGL is a good investment considering market position, competitors, and financials",
enable_thinking_tool=True,
enable_reasoning_tool=True
)
result2 = agent.do(complex_task)
print("Complex task result:", result2)