yival.output_parsers.base_parser¶
BaseParserWithRegistry Objects¶
class BaseParserWithRegistry()
Base class for parsers that provides automatic registration of subclasses. Any subclass that inherits from this base class will be automatically added to the registry. The registry can then be used to retrieve a parser class based on its name.
registry¶
Class-level registry for all parser subclasses
__init_subclass__¶
def __init_subclass__(cls, **kwargs)
Automatically called when a subclass is defined.
parse¶
def parse(output: str) -> List[str]
Parse the provided output. This method should be overridden by subclasses to provide custom parsing logic.
yival.output_parsers.utils¶
capture_and_parse_with_base_registry¶
def capture_and_parse_with_base_registry(config=None)
Decorator to capture stdout of a function and parse it using a specified parser.
The parser is determined based on the provided configuration. If the specified parser is not found in the BaseParserWithRegistry's registry, the function's output will not be captured or parsed.
Arguments:
- config (dict, optional): Configuration dict with 'parser' key specifying the parser class name.
Returns:
- Decorated function that captures and parses its stdout.