react_agent/
react_agent.rs1use helios_engine::{Agent, CalculatorTool, Config, EchoTool, FileReadTool};
8
9#[tokio::main]
10async fn main() -> helios_engine::Result<()> {
11 println!("🧠 Helios Engine - ReAct Agent Example");
12 println!("======================================\n");
13
14 let config = Config::from_file("config.toml")?;
16
17 let mut agent = Agent::builder("ReActAgent")
20 .config(config)
21 .system_prompt(
22 "You are a helpful assistant that thinks carefully before acting. \
23 Use your reasoning to plan your approach.",
24 )
25 .tools(vec![
26 Box::new(CalculatorTool),
27 Box::new(EchoTool),
28 Box::new(FileReadTool),
29 ])
30 .react() .max_iterations(5)
32 .build()
33 .await?;
34
35 println!(
36 "Available tools: {:?}\n",
37 agent.tool_registry().list_tools()
38 );
39
40 println!("═══════════════════════════════════════════════════════════");
41 println!("Example 1: Mathematical Problem");
42 println!("═══════════════════════════════════════════════════════════\n");
43
44 println!("User: I need to calculate (25 * 4) + (100 / 5). Can you help?\n");
46 let response = agent
47 .chat("I need to calculate (25 * 4) + (100 / 5). Can you help?")
48 .await?;
49 println!("\nAgent: {}\n", response);
50
51 println!("═══════════════════════════════════════════════════════════");
52 println!("Example 2: Multi-step Task");
53 println!("═══════════════════════════════════════════════════════════\n");
54
55 println!("User: First calculate 15 * 7, then echo the result back to me.\n");
57 let response = agent
58 .chat("First calculate 15 * 7, then echo the result back to me.")
59 .await?;
60 println!("\nAgent: {}\n", response);
61
62 println!("═══════════════════════════════════════════════════════════");
63 println!(" ReAct Demo Complete!");
64 println!("═══════════════════════════════════════════════════════════");
65 println!("\nNotice how the agent:");
66 println!(" 1. 💭 First reasons about the task");
67 println!(" 2. 📋 Creates a plan");
68 println!(" 3. ⚡ Then executes the actions\n");
69 println!("This leads to more thoughtful and systematic problem-solving!");
70
71 Ok(())
72}