跳到主要内容

openhands.agenthub.browsing_agent.utils

yaml_parser

def yaml_parser(message)

Parse a yaml message for the retry function.

compress_string

def compress_string(text)

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

extract_html_tags

def extract_html_tags(text, keys)

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,
keys=(),
optional_keys=(),
merge_multiple=False)

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

parse_html_tags

def parse_html_tags(text, keys=(), optional_keys=(), merge_multiple=False)

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.