react_custom_prompt/
react_custom_prompt.rs1use helios_engine::{Agent, CalculatorTool, Config, FileReadTool};
7
8#[tokio::main]
9async fn main() -> helios_engine::Result<()> {
10 println!("🧠 Helios Engine - ReAct with Custom Prompts");
11 println!("=============================================\n");
12
13 let config = Config::from_file("config.toml")?;
14
15 println!("═══════════════════════════════════════════════════════════");
17 println!("Example 1: Mathematical Problem Solver");
18 println!("═══════════════════════════════════════════════════════════\n");
19
20 let math_prompt = r#"As a mathematical problem solver, analyze this systematically:
21
221. IDENTIFY: What mathematical operations are required?
232. DECOMPOSE: Break complex calculations into simple steps
243. ORDER: Determine the correct order of operations (PEMDAS/BODMAS)
254. PLAN: List which calculator functions to use and in what sequence
265. VERIFY: Consider how to check the answer
27
28Provide your mathematical reasoning clearly."#;
29
30 let mut math_agent = Agent::builder("MathExpert")
31 .config(config.clone())
32 .system_prompt("You are a mathematical expert who thinks carefully about calculations.")
33 .tool(Box::new(CalculatorTool))
34 .react_with_prompt(math_prompt)
35 .build()
36 .await?;
37
38 println!("User: Calculate ((15 * 8) + (20 * 3)) / 2\n");
39 let response = math_agent
40 .chat("Calculate ((15 * 8) + (20 * 3)) / 2")
41 .await?;
42 println!("\nAgent: {}\n", response);
43
44 println!("═══════════════════════════════════════════════════════════");
46 println!("Example 2: Data Analysis Agent");
47 println!("═══════════════════════════════════════════════════════════\n");
48
49 let data_prompt = r#"As a data analyst, approach this task methodically:
50
511. UNDERSTAND: What data or files are we working with?
522. EXTRACT: What information needs to be retrieved?
533. PROCESS: What transformations or calculations are needed?
544. TOOLS: Which tools should I use and in what order?
555. OUTPUT: What format should the final answer take?
56
57Think through the data pipeline step by step."#;
58
59 let mut data_agent = Agent::builder("DataAnalyst")
60 .config(config.clone())
61 .system_prompt("You are a data analyst who carefully plans data processing tasks.")
62 .tools(vec![Box::new(FileReadTool), Box::new(CalculatorTool)])
63 .react_with_prompt(data_prompt)
64 .build()
65 .await?;
66
67 println!("User: If I have numbers 10, 20, 30, 40, 50, what's their average?\n");
68 let response = data_agent
69 .chat("If I have numbers 10, 20, 30, 40, 50, what's their average?")
70 .await?;
71 println!("\nAgent: {}\n", response);
72
73 println!("═══════════════════════════════════════════════════════════");
75 println!("Example 3: Task Planning Agent");
76 println!("═══════════════════════════════════════════════════════════\n");
77
78 let planning_prompt = r#"As a task planning expert, organize this systematically:
79
801. GOAL: What is the end objective?
812. PREREQUISITES: What information do I already have?
823. DEPENDENCIES: What needs to happen before what?
834. RESOURCES: What tools are available to me?
845. STEPS: Create a numbered action plan
856. CONTINGENCY: What could go wrong?
86
87Plan the execution strategy carefully."#;
88
89 let mut planning_agent = Agent::builder("TaskPlanner")
90 .config(config.clone())
91 .system_prompt("You are a strategic planner who breaks down complex tasks.")
92 .tool(Box::new(CalculatorTool))
93 .react_with_prompt(planning_prompt)
94 .build()
95 .await?;
96
97 println!("User: I need to calculate the total cost: 5 items at $12.50 each, plus 8% tax\n");
98 let response = planning_agent
99 .chat("I need to calculate the total cost: 5 items at $12.50 each, plus 8% tax")
100 .await?;
101 println!("\nAgent: {}\n", response);
102
103 println!("═══════════════════════════════════════════════════════════");
105 println!("Example 4: Scientific Reasoning Agent");
106 println!("═══════════════════════════════════════════════════════════\n");
107
108 let scientific_prompt = r#"Apply the scientific method to this problem:
109
1101. OBSERVATION: What is being asked?
1112. HYPOTHESIS: What approach should work?
1123. VARIABLES: What factors are involved?
1134. METHOD: What tools and operations are needed?
1145. PREDICTION: What result do we expect?
1156. VERIFICATION: How can we validate the answer?
116
117Use rigorous scientific thinking."#;
118
119 let mut science_agent = Agent::builder("Scientist")
120 .config(config)
121 .system_prompt("You are a scientist who applies rigorous methodology.")
122 .tool(Box::new(CalculatorTool))
123 .react_with_prompt(scientific_prompt)
124 .build()
125 .await?;
126
127 println!("User: If velocity = 30 m/s and time = 4 seconds, what's the distance?\n");
128 let response = science_agent
129 .chat("If velocity = 30 m/s and time = 4 seconds, what's the distance?")
130 .await?;
131 println!("\nAgent: {}\n", response);
132
133 println!("═══════════════════════════════════════════════════════════");
134 println!(" Custom Prompt Demo Complete!");
135 println!("═══════════════════════════════════════════════════════════");
136 println!("\nKey Takeaways:");
137 println!(" • Custom prompts tailor reasoning to specific domains");
138 println!(" • Different prompts optimize for different task types");
139 println!(" • Use .react_with_prompt() for domain-specific reasoning");
140 println!(" • Each agent can have its own reasoning style\n");
141
142 Ok(())
143}