Spaces:
Build error
Build error
Download src/infrastructure/tools/browser.py from fariasultanacodes/gemini-agent: direct link, hf CLI and curl.
- Browser
- Download file 846 Bytes
-
https://huggingface.co/spaces/fariasultanacodes/gemini-agent/resolve/main/src/infrastructure/tools/browser.py
- Command line
-
hf download hf://spaces/fariasultanacodes/gemini-agent/src/infrastructure/tools/browser.py
-
curl -L -o browser.py https://huggingface.co/spaces/fariasultanacodes/gemini-agent/resolve/main/src/infrastructure/tools/browser.py
846 Bytes
| 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 | |
| ) | |