map_over

Function map_over 

Source
pub fn map_over(agent: AgentBuilder, list_key: impl Into<String>) -> Composable
Expand description

Map-over: apply one agent to every item of a state list.

At run time the compiled node reads the JSON array at state[list_key], runs agent once per item with the item in state["_item"] (and as the agent’s input), and collects the outputs into state["_results"]. Items run sequentially — MapOver::item_key/output_key rename the slots. Composes like any other node:

let batch = map_over(AgentBuilder::new("summarize"), "documents")
    >> AgentBuilder::new("merge");
assert!(matches!(batch, Composable::Pipeline(_)));