Router
Route requests to appropriate agents
Router directs requests to the most appropriate agent.
Quick Start
- Create Agent Router
rust use praisonai::{Agent, when}; // Create specialized agents let tech_agent = Agent::new() .name("Tech Support") .instructions("Help with technical issues") .build()?; let sales_agent = Agent::new() .name("Sales") .instructions("Handle sales inquiries") .build()?; let support_agent = Agent::new() .name("Support") .instructions("General customer support") .build()?; // Create router with conditions let router = when(|input: &str| input.contains("API") || input.contains("error")) .then(tech_agent) .when(|input: &str| input.contains("price") || input.contains("buy")) .then(sales_agent) .otherwise(support_agent); router.run("I need help with an API error").await?; // Routes to tech_agent
Routing Strategies
| Strategy | Description |
|---|---|
| Keyword | Match keywords in input |
| Semantic | Use embeddings to classify |
| LLM | Use LLM to decide |
| Rules | Custom routing rules |