Skip to main content

openhands.agenthub.browsing_agent.utils

yaml_parser

def yaml_parser(message: str) -> tuple[dict, bool, str]

Parse a yaml message for the retry function.

compress_string

def compress_string(text: str) -> str

Compress a string by replacing redundant paragraphs and lines with identifiers.

extract_html_tags

def extract_html_tags(text: str, keys: list[str]) -> dict[str, list[str]]

Extract the content within HTML tags for a list of keys.

Parameters

text : str The input string containing the HTML tags. keys : list of str The HTML tags to extract the content from.

Returns:


dict A dictionary mapping each key to a list of subset in text that match the key.

Notes:


All text and keys will be converted to lowercase before matching.

parse_html_tags_raise

def parse_html_tags_raise(text: str,
keys: list[str] | None = None,
optional_keys: list[str] | None = None,
merge_multiple: bool = False) -> dict[str, str]

A version of parse_html_tags that raises an exception if the parsing is not successful.

parse_html_tags

def parse_html_tags(
text: str,
keys: list[str] | None = None,
optional_keys: list[str] | None = None,
merge_multiple: bool = False) -> tuple[dict[str, str], bool, str]

Satisfy the parse api, extracts 1 match per key and validates that all keys are present

Parameters

text : str The input string containing the HTML tags. keys : list of str The HTML tags to extract the content from. optional_keys : list of str The HTML tags to extract the content from, but are optional.

Returns:


dict A dictionary mapping each key to subset of text that match the key. bool Whether the parsing was successful. str A message to be displayed to the agent if the parsing was not successful.