conditionalEdge
Adds a conditional edge: after from finishes, condition picks the next node from the state.
Declare the possible targets whenever you can. They are checked when the graph is compiled, the value returned by condition is checked against them at run time, and they let compile detect unreachable nodes. With targets = null the condition may return any node name.
A node can have either one conditional edge or static edges, not both.
labels say when the edge goes to some of its targets, such as mapOf("write" to "too short"), and are the labels of CompiledGraph.toMermaid. Each needs its target in targets.
Adds a conditional edge from the node referenced by from. See the overload taking a node name.
Adds a conditional edge that works with references instead of names: condition returns one of targets, so a misspelled node is a compiler error.
conditionalEdge(check, targets = setOf(write, NodeRef.END)) { draft ->
if (draft.isGood) NodeRef.END else write
}To finish the branch, list NodeRef.END in targets and return it. labels say when the edge goes to some of the targets, such as mapOf(write to "too short"), for CompiledGraph.toMermaid.
Adds a conditional edge that works with references, from the node named from, usually START. See the overload taking a node reference.