from pydantic_ai import Agent, RunContext
import httpx
agent = Agent('openai:gpt-4o-mini')
@agent.tool
async def get_weather(ctx: RunContext[None], location: str) -> str:
"""Get current weather for a location."""
# Simulate weather API call
return f"The weather in {location} is sunny and 75°F"
@agent.tool
async def search_web(ctx: RunContext[None], query: str) -> str:
"""Search the web for information."""
# Simulate web search
return f"Search results for '{query}': Found relevant information about the topic."
# Use the agent with tools
result = agent.run_sync('What is the weather like in San Francisco and find recent news about climate change?')
print(result.data)