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ΒΆ

Branch

Unified branch for dynamic routing based on state values.

Module ContentsΒΆ

class haive.core.graph.branches.branch.Branch(/, **data)[source]ΒΆ

Bases: pydantic.BaseModel

Unified 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

evaluator(state)[source]ΒΆ

Evaluate the branch condition and return the next node.

Parameters:

state (dict[str, Any]) – Current graph state

Returns:

Name of the next node

Return type:

str

extract_field_references()[source]ΒΆ

Extract field references used by this branch.

Return type:

set[str]

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].