agents.base.smart_output_parsing

Smart Output Parsing with Post-Hooks Integration.

This module demonstrates how to use GenericEngineNodeConfig and post-hooks to handle specific output parsing in a smart, flexible manner.

Classes

SmartCallableOutputParser

CallableNodeConfig specialized for output parsing with smart routing.

SmartGenericEngineNode

Enhanced GenericEngineNodeConfig with smart output parsing.

SmartOutputParsingMixin

Mixin to add smart output parsing capabilities to agents.

Functions

create_smart_engine_node(engine, name[, input_schema, ...])

Create a smart generic engine node with output parsing.

create_smart_parsing_callable(parsing_functions, ...)

Create a smart callable parser with content detection.

detect_content_type(state)

Example content type detection function.

parse_json_content(state)

Example JSON parsing function.

parse_structured_content(state)

Example structured content parsing function.

Module Contents

class agents.base.smart_output_parsing.SmartCallableOutputParser(/, **data)

Bases: haive.core.graph.node.callable_node.CallableNodeConfig

CallableNodeConfig specialized for output parsing with smart routing.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

class agents.base.smart_output_parsing.SmartGenericEngineNode

Bases: haive.core.graph.node.engine_node_generic.GenericEngineNodeConfig[TInput, TOutput]

Enhanced GenericEngineNodeConfig with smart output parsing.

class agents.base.smart_output_parsing.SmartOutputParsingMixin(*args, **kwargs)

Mixin to add smart output parsing capabilities to agents.

Init .

agents.base.smart_output_parsing.create_smart_engine_node(engine, name, input_schema=None, output_schema=None, parsing_strategies=None, **kwargs)

Create a smart generic engine node with output parsing.

Parameters:
  • name (str)

  • input_schema (type[pydantic.BaseModel] | None)

  • output_schema (type[pydantic.BaseModel] | None)

  • parsing_strategies (list[str] | None)

Return type:

SmartGenericEngineNode

agents.base.smart_output_parsing.create_smart_parsing_callable(parsing_functions, detection_function, name='smart_parser', **kwargs)

Create a smart callable parser with content detection.

Parameters:
Return type:

SmartCallableOutputParser

agents.base.smart_output_parsing.detect_content_type(state)

Example content type detection function.

Return type:

str

agents.base.smart_output_parsing.parse_json_content(state)

Example JSON parsing function.

Return type:

dict

agents.base.smart_output_parsing.parse_structured_content(state)

Example structured content parsing function.

Return type:

dict