tooluniverse.url_tool module

class tooluniverse.url_tool.BaseTool(tool_config)[source][source]

Bases: object

__init__(tool_config)[source][source]
classmethod get_default_config_file()[source][source]

Get the path to the default configuration file for this tool type.

This method uses a robust path resolution strategy that works across different installation scenarios:

  1. Installed packages: Uses importlib.resources for proper package resource access

  2. Development mode: Falls back to file-based path resolution

  3. Legacy Python: Handles importlib.resources and importlib_resources

Override this method in subclasses to specify a custom defaults file.

Returns:

Path or resource object pointing to the defaults file

classmethod load_defaults_from_file()[source][source]

Load defaults from the configuration file

run(arguments=None)[source][source]

Execute the tool.

The default BaseTool implementation accepts an optional arguments mapping to align with most concrete tool implementations which expect a dictionary of inputs.

check_function_call(function_call_json)[source][source]
get_required_parameters()[source][source]

Retrieve required parameters from the endpoint definition. Returns: list: List of required parameters for the given endpoint.

tooluniverse.url_tool.unescape(s)[source][source]

Convert all named and numeric character references (e.g. >, >, &x3e;) in the string s to the corresponding unicode characters. This function uses the rules defined by the HTML 5 standard for both valid and invalid character references, and the list of HTML 5 named character references defined in html.entities.html5.

tooluniverse.url_tool.register_tool(tool_type_name=None, config=None)[source][source]

Decorator to automatically register tool classes and their configs.

Usage:

@register_tool(‘CustomToolName’, config={…}) class MyTool:

pass

tooluniverse.url_tool.sync_playwright() PlaywrightContextManager[source][source]
class tooluniverse.url_tool.URLHTMLTagTool(tool_config)[source][source]

Bases: BaseTool

Fetches a webpage and extracts the content of a specified HTML tag. Expects: {“url”: “https://…”} The tag to extract is specified in the tool’s configuration. The tag to extract is specified in the tool’s configuration. Optional: {“timeout”: <seconds>} (default 20) Returns: {“content”: “<extracted content>”} or {“error”: “…”}

__init__(tool_config)[source][source]
run(arguments: dict)[source][source]

Execute the tool.

The default BaseTool implementation accepts an optional arguments mapping to align with most concrete tool implementations which expect a dictionary of inputs.

class tooluniverse.url_tool.URLToPDFTextTool(tool_config)[source][source]

Bases: BaseTool

Loads a webpage (with JavaScript), exports it as a PDF, and extracts text. Expects: {“url”: “https://…”} Optional: {“timeout”: <seconds>} (default 30) Returns: {“text”: “<extracted text>”} or {“error”: “…”}

__init__(tool_config)[source][source]
run(arguments: dict)[source][source]

Execute the tool.

The default BaseTool implementation accepts an optional arguments mapping to align with most concrete tool implementations which expect a dictionary of inputs.