pub struct Router;
Router helper functions for common patterns
Route based on a state field value
.conditional_edge("supervisor", Router::by_field("next_agent"), targets)
Route based on whether the last message has tool calls
.conditional_edge("agent", Router::has_tool_calls("messages", "tools", END), targets)
Route based on a boolean state field
.conditional_edge("check", Router::by_bool("should_continue", "process", END), targets)
Route based on iteration count
.conditional_edge("loop", Router::max_iterations("iteration", 5, "continue", "done"), targets)
Route based on the presence of an error
.conditional_edge("process", Router::on_error("error", "error_handler", "success"), targets)
Create a custom router from a closure
.conditional_edge("agent", Router::custom(|state| { if state.get("done").and_then(|v| v.as_bool()).unwrap_or(false) { END.to_string() } else { "continue".to_string() } }), targets)
TypeId
self
Returns the argument unchanged.
Calls U::from(self).
U::from(self)
That is, this conversion is whatever the implementation of From<T> for U chooses to do.
From<T> for U