Skip to main content

human

Function human 

Source
pub fn human(question: impl Into<String>) -> HumanNode
Expand description

A graph node that asks a person question, with its input as the question’s context, and outputs their answer.

Only a streamed run can ask; a plain run fails at this node. To gate work on an answer, put the condition on the edges into the gated node, from the human node and from the work:

use rig_multiagent::{Graph, GraphState, human, node_fn};
let approved = |state: &GraphState| state.output("approve") == Some("yes");
let graph = Graph::builder()
    .node("build", build)
    .node("approve", human("Deploy this release? (yes/no)"))
    .node("deploy", deploy)
    .edge("build", "approve")
    .edge_if("approve", "deploy", approved)
    .edge_if("build", "deploy", approved) // so deploy gets the build too
    .build()?;