from agno.agent import Agent
from agno.tools.browserbase import BrowserbaseTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
# ==================== Usage ====================
# BrowserbaseTools automatically uses the correct implementation based on context:
# - Sync tools when using agent.run() or agent.print_response()
# - Async tools when using agent.arun() or agent.aprint_response()
agent = Agent(
name="Web Automation Assistant",
tools=[BrowserbaseTools()],
instructions=[
"You are a web automation assistant that can help with:",
"1. Capturing screenshots of websites",
"2. Extracting content from web pages",
"3. Monitoring website changes",
"4. Taking visual snapshots of responsive layouts",
"5. Automated web testing and verification",
],
markdown=True,
)
# ==================== Sync Usage ====================
# Use this for regular scripts and synchronous execution
# Content Extraction and SS
# agent.print_response("""
# Go to https://news.ycombinator.com and extract:
# 1. The page title
# 2. Take a screenshot of the top stories section
# """)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
agent.print_response("""
Visit https://quotes.toscrape.com and:
1. Extract the first 5 quotes and their authors
2. Navigate to page 2
3. Extract the first 5 quotes from page 2
""")
# ==================== Async Usage ====================
# Use this for FastAPI, async frameworks, or when using agent.arun()
# The same agent instance works for both sync and async - just use arun/aprint_response!
# import asyncio
#
#
# async def main():
# # Same agent, just use async methods - it will automatically use async tools
# await agent.aprint_response("""
# Visit https://quotes.toscrape.com and:
# 1. Extract the first 5 quotes and their authors
# 2. Navigate to page 2
# 3. Extract the first 5 quotes from page 2
# """)
#
#
# if __name__ == "__main__":
# asyncio.run(main())