Conditions
tools_condition is the router for the model-to-tools edge. It returns "tools" when the last message has tool calls, and END ("__end__") otherwise.
use warpra_prebuilt::tools_condition;
g.add_conditional_edges("model", |s: &serde_json::Value| tools_condition(s), None)?;g.add_edge("tools", "model")?;Two variants
Section titled “Two variants”| Function | Signature | On a state without messages |
|---|---|---|
tools_condition(state) |
&Value -> &'static str |
Routes to END |
tools_condition_with_key(state, key) |
(&Value, &str) -> Result<&'static str, ConditionError> |
Returns ConditionError::NoMessages |
state can be a messages list or an object with the messages under the key (messages for tools_condition). A router cannot fail inside the graph, which is why tools_condition falls back to END. Call tools_condition_with_key when you want the error.
Warpra is open source under Apache-2.0. Made by Liceron.