Skip to content

trading_agent.tools.browser_snapshot_tool

The browser_snapshot tool: lists the current page's numbered elements and text again.

Typical usage example:

tool = BrowserSnapshotTool(session)

BrowserSnapshotTool

BrowserSnapshotTool(session)

Bases: BrowserTool

Takes a fresh snapshot of the current page.

Source code in src/trading_agent/tools/browser_tool.py
def __init__(self, session: browser_session_module.BrowserSession):
    """Creates the tool.

    Args:
        session (browser_session_module.BrowserSession): The desk's browser.
    """
    self._session = session

run async

run(arguments)

Takes the snapshot.

Parameters:

Name Type Description Default
arguments NoArguments

No arguments.

required

Returns:

Type Description
ToolResult

The snapshot, or an error.

Source code in src/trading_agent/tools/browser_snapshot_tool.py
async def run(self, arguments: tool.NoArguments) -> tool.ToolResult:
    """Takes the snapshot.

    Args:
        arguments (tool.NoArguments): No arguments.

    Returns:
        tool.ToolResult: The snapshot, or an error.
    """
    del arguments
    return await self._text_result(self._session.snapshot())