haive.core.graph.branches.branch¶
Core Branch implementation for dynamic routing.
This module provides a unified Branch class that replaces the need for separate ConditionalEdge objects, consolidating all routing logic.
Classes¶
Unified branch for dynamic routing based on state values. |
Module Contents¶
- class haive.core.graph.branches.branch.Branch(/, **data)[source]¶
Bases:
pydantic.BaseModelUnified branch for dynamic routing based on state values.
This class combines the functionality of branch routing and conditional edges, providing a single unified interface for graph 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)
- evaluate(state)[source]¶
Evaluate the branch against state.
- Parameters:
state (haive.core.graph.common.types.StateLike)
- Return type:
haive.core.graph.common.types.NodeOutput
- setup_function_and_mappings()[source]¶
Set up function and mappings after initialization.
- Return type:
Self
- validate_destinations_and_default()[source]¶
Validate destinations and set default if needed.
- Return type:
Self
- model_config¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].