Skip to content

trading_agent.tools.browser_type_tool

The browser_type tool: types into a numbered field from the latest snapshot.

Typical usage example:

tool = BrowserTypeTool(session)

BrowserTypeArguments

Bases: BaseModel

The arguments of browser_type.

Attributes:

Name Type Description
element int

The field's number from the latest snapshot.

text str

What to type; it replaces what the field holds.

submit bool

Whether to press Enter afterwards, for example to run a search.

BrowserTypeTool

BrowserTypeTool(session)

Bases: BrowserTool

Types into a field.

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)

Types the text.

Parameters:

Name Type Description Default
arguments BrowserTypeArguments

The field, the text and whether to submit.

required

Returns:

Type Description
ToolResult

The new snapshot, or an error.

Source code in src/trading_agent/tools/browser_type_tool.py
async def run(self, arguments: BrowserTypeArguments) -> tool.ToolResult:
    """Types the text.

    Args:
        arguments (BrowserTypeArguments): The field, the text and whether to submit.

    Returns:
        tool.ToolResult: The new snapshot, or an error.
    """
    return await self._text_result(
        self._session.type_text(
            arguments.element,
            arguments.text,
            arguments.submit,
        )
    )