haive.core.schema.prebuilt.validation_routing_example

Example of LangGraph validation nodes with Send branching for tool routing.

This example demonstrates: 1. How validation nodes return routing decisions using Send objects 2. How Send objects are created from validation results 3. How tool routes map to destination nodes 4. Examples of splitting tool calls based on validation

Classes

ValidationExample

Example state that extends EnhancedToolState for validation routing.

Functions

agent_node(state)

Agent node that can make tool calls.

build_validation_graph()

Build a graph demonstrating validation routing with Send.

langchain_tools_node(tool_call)

Execute LangChain tools.

pydantic_tools_node(tool_call)

Execute Pydantic model tools.

validation_node(state)

Validation node that routes tool calls based on validation results.

Module Contents

class haive.core.schema.prebuilt.validation_routing_example.ValidationExample(/, **data)[source]

Bases: pydantic.BaseModel

Example state that extends EnhancedToolState for validation 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)

haive.core.schema.prebuilt.validation_routing_example.agent_node(state)[source]

Agent node that can make tool calls.

Parameters:

state (haive.core.schema.prebuilt.tool_state_with_validation.EnhancedToolState)

Return type:

dict[str, Any]

haive.core.schema.prebuilt.validation_routing_example.build_validation_graph()[source]

Build a graph demonstrating validation routing with Send.

Return type:

langgraph.graph.StateGraph

haive.core.schema.prebuilt.validation_routing_example.langchain_tools_node(tool_call)[source]

Execute LangChain tools.

Parameters:

tool_call (dict[str, Any])

Return type:

dict[str, Any]

haive.core.schema.prebuilt.validation_routing_example.pydantic_tools_node(tool_call)[source]

Execute Pydantic model tools.

Parameters:

tool_call (dict[str, Any])

Return type:

dict[str, Any]

haive.core.schema.prebuilt.validation_routing_example.validation_node(state)[source]

Validation node that routes tool calls based on validation results.

This node demonstrates: 1. Validating tool calls from the last AI message 2. Creating Send objects for valid tools based on their routes 3. Handling different validation statuses (valid, invalid, error) 4. Routing to different nodes based on tool_routes from state/engine

Returns:

For routing valid tool calls to appropriate nodes - “agent”: To return to agent for clarification - END: To end processing if no valid tools

Return type:

  • List[Send]

Parameters:

state (haive.core.schema.prebuilt.tool_state_with_validation.EnhancedToolState)