haive.agents.chain.declarative_chain¶

Declarative chain building for complex agent workflows.

Provides declarative specification and building of complex agent chains with branching, loops, and conditional execution.

Classes¶

BranchSpec

Specification for conditional branching.

ChainBuilder

Builder for creating declarative chains.

ChainSpec

Complete specification for a declarative chain.

DeclarativeChainAgent

Agent that executes a declaratively defined chain.

LoopSpec

Specification for loops in the chain.

NodeSpec

Specification for a single node in a chain.

SequenceSpec

Specification for a sequence of nodes.

Functions¶

complex_rag(*args, **kwargs)

Create a complex RAG chain using declarative building.

Module Contents¶

class haive.agents.chain.declarative_chain.BranchSpec¶

Specification for conditional branching.

class haive.agents.chain.declarative_chain.ChainBuilder(name)¶

Builder for creating declarative chains.

Init .

Parameters:

name (str) – [TODO: Add description]

add_branch(from_node, condition, branches, default=None)¶

Add conditional branching.

Parameters:
Return type:

ChainBuilder

add_loop(start_node, end_node, condition, max_iterations=10)¶

Add a loop.

Parameters:
Return type:

ChainBuilder

add_node(name, node, node_type='agent')¶

Add a node to the chain.

Parameters:
  • name (str)

  • node (Any)

  • node_type (str)

Return type:

ChainBuilder

add_sequence(*nodes)¶

Add a sequence of nodes.

Parameters:

nodes (str)

Return type:

ChainBuilder

build()¶

Build the final chain agent.

Return type:

DeclarativeChainAgent

class haive.agents.chain.declarative_chain.ChainSpec¶

Complete specification for a declarative chain.

class haive.agents.chain.declarative_chain.DeclarativeChainAgent(name, chain_spec)¶

Agent that executes a declaratively defined chain.

Init .

Parameters:
  • name (str) – [TODO: Add description]

  • chain_spec (ChainSpec) – [TODO: Add description]

async arun(input_data)¶

Execute the chain asynchronously.

Parameters:

input_data (dict[str, Any])

Return type:

dict[str, Any]

run(input_data)¶

Execute the chain.

Parameters:

input_data (dict[str, Any])

Return type:

dict[str, Any]

class haive.agents.chain.declarative_chain.LoopSpec¶

Specification for loops in the chain.

class haive.agents.chain.declarative_chain.NodeSpec¶

Specification for a single node in a chain.

class haive.agents.chain.declarative_chain.SequenceSpec¶

Specification for a sequence of nodes.

haive.agents.chain.declarative_chain.complex_rag(*args, **kwargs)¶

Create a complex RAG chain using declarative building.