File size: 846 Bytes
ad8ba8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from playwright.async_api import async_playwright
from src.infrastructure.tools.registry import tool_registry

async def browser_navigate(url: str) -> str:
    """Navigate to a URL and return the page content"""
    async with async_playwright() as p:
        browser = await p.chromium.launch(headless=True)
        page = await browser.new_page()
        await page.goto(url)
        content = await page.content()
        await browser.close()
        return content[:2000] # Return first 2000 chars for now

tool_registry.register(
    name="browser_navigate",
    description="Navigate to a website and get its content",
    parameters={
        "type": "OBJECT",
        "properties": {
            "url": {"type": "STRING", "description": "The URL to navigate to"}
        },
        "required": ["url"]
    },
    func=browser_navigate
)