agents.chain.chain_agent_simple¶
ChainAgent - The simplest way to build agent chains.
Just list your nodes and define the flow. That’s it.
Classes¶
The simplest way to build chains - just list nodes and edges. |
|
Builder for method chaining. |
Functions¶
|
Create a flow chain - the simplest way. |
|
Create a flow with custom edges. |
Module Contents¶
- class agents.chain.chain_agent_simple.ChainAgent(*nodes, **kwargs)¶
Bases:
haive.agents.base.agent.Agent
The simplest way to build chains - just list nodes and edges.
Initialize with nodes directly.
Examples
ChainAgent(node1, node2, node3) # Auto-sequential ChainAgent(node1, node2, edges=[“0->1”])
- Parameters:
nodes (NodeLike)
- add(node)¶
Add a node and auto-link from previous.
- Parameters:
node (NodeLike)
- Return type:
- branch(condition, **branches)¶
Add conditional branching.
- Parameters:
condition (collections.abc.Callable)
branches (NodeLike)
- Return type:
- build_graph()¶
Build the graph from nodes and edges.
- Return type:
haive.core.graph.state_graph.base_graph2.BaseGraph
- class agents.chain.chain_agent_simple.FlowBuilder(initial=None)¶
Builder for method chaining.
Init .
- Parameters:
initial (NodeLike | None) – [TODO: Add description]
- add(node)¶
Add a node.
- Parameters:
node (NodeLike)
- Return type:
- branch(condition, **branches)¶
Add branching.
- Parameters:
condition (collections.abc.Callable)
branches (NodeLike)
- Return type:
- build()¶
Get the chain.
- Return type:
- agents.chain.chain_agent_simple.flow(*nodes, **kwargs)¶
Create a flow chain - the simplest way.
Examples
# Sequential chain = flow(node1, node2, node3)
# With edges chain = flow(node1, node2, node3, edges=[“0->2”]) # Skip node2
# With name chain = flow(node1, node2, name=”My Flow”)
- Parameters:
nodes (NodeLike)
- Return type:
- agents.chain.chain_agent_simple.flow_with_edges(nodes, *edges)¶
Create a flow with custom edges.
Examples
- chain = flow_with_edges(
[classifier, simple, complex, output], (0, {“simple”: 1, “complex”: 2}, lambda s: s.type), “1->3”, “2->3”
)
- Parameters:
nodes (list[NodeLike])
edges (EdgeLike)
- Return type: