Routing
Route requests between agents
Routing directs requests to appropriate agents.
graph TB
subgraph "Routing"
R[๐ฅ Request] --> RT{๐ Route}
RT --> A1[๐ค Agent A]
RT --> A2[๐ค Agent B]
RT --> A3[๐ค Agent C]
end
classDef router fill:#6366F1,stroke:#7C90A0,color:#fff
classDef agent fill:#10B981,stroke:#7C90A0,color:#fff
class R,RT router
class A1,A2,A3 agentQuick Start
- Route Requests to Agents
rust use praisonai::{Agent, when}; // Create specialized agents let coder = Agent::new() .name("Coder") .instructions("You help with programming tasks") .build()?; let writer = Agent::new() .name("Writer") .instructions("You help with writing tasks") .build()?; // Route based on input content let router = when(|input: &str| input.contains("code")) .then(coder) .otherwise(writer); router.run("Help me write code").await?; // Routes to coder agent - Multi-Route Configuration
rust use praisonai::when; let router = when(|i| i.contains("code")) .then(coder) .when(|i| i.contains("write")) .then(writer) .otherwise(general);