complete_demo/
complete_demo.rs1use helios_engine::{Agent, Config, FileEditTool, FileReadTool, FileSearchTool, FileWriteTool};
9use std::io::{self, Write};
10
11#[tokio::main]
12async fn main() -> helios_engine::Result<()> {
13 println!("š Helios Engine - Complete Feature Demo");
14 println!("=========================================\n");
15
16 let config = Config::from_file("config.toml").unwrap_or_else(|_| {
18 println!("ā No config.toml found, using default configuration");
19 Config::new_default()
20 });
21
22 println!("š¦ Creating agent with file tools...");
24 let mut agent = Agent::builder("SmartAssistant")
25 .config(config)
26 .system_prompt(
27 "You are an intelligent assistant with file management capabilities. \
28 You can search files, read them, and make edits. Always explain what \
29 you're doing and track important information in session memory.",
30 )
31 .tool(Box::new(FileSearchTool))
32 .tool(Box::new(FileReadTool))
33 .tool(Box::new(FileEditTool))
34 .tool(Box::new(FileWriteTool))
35 .max_iterations(10)
36 .build()
37 .await?;
38
39 println!("ā Agent created successfully!\n");
40
41 println!("š§ Initializing session memory...");
43 agent.set_memory("session_start", chrono::Utc::now().to_rfc3339());
44 agent.set_memory(
45 "working_directory",
46 std::env::current_dir()?.display().to_string(),
47 );
48 agent.set_memory("files_accessed", "0");
49 agent.set_memory("edits_made", "0");
50 println!("ā Session memory initialized\n");
51
52 println!("Demo 1: File Search with Streaming");
54 println!("===================================");
55 println!("User: Find all Rust example files\n");
56
57 print!("Agent: ");
58 io::stdout().flush()?;
59
60 let response1 = agent
61 .chat("Find all Rust example files in the examples directory")
62 .await?;
63 println!("{}\n", response1);
64
65 agent.increment_counter("files_accessed");
67 agent.set_memory("last_action", "file_search");
68
69 println!("\nDemo 2: Reading File Contents");
71 println!("==============================");
72 println!("User: Read the NEW_FEATURES.md file and summarize the key points\n");
73
74 print!("Agent: ");
75 io::stdout().flush()?;
76
77 let response2 = agent
78 .chat("Read the NEW_FEATURES.md file and give me a brief summary of what's new")
79 .await?;
80 println!("{}\n", response2);
81
82 agent.increment_counter("files_accessed");
84 agent.set_memory("last_action", "file_read");
85
86 println!("\nDemo 3: Session Summary");
88 println!("=======================\n");
89 println!("{}", agent.get_session_summary());
90
91 println!("\n\nDemo 4: Interactive Mode");
93 println!("========================");
94 println!("You can now interact with the agent. Type 'exit' to quit.\n");
95
96 loop {
97 print!("\nYou: ");
98 io::stdout().flush()?;
99
100 let mut input = String::new();
101 io::stdin().read_line(&mut input)?;
102 let input = input.trim();
103
104 if input.is_empty() {
105 continue;
106 }
107
108 match input.to_lowercase().as_str() {
109 "exit" | "quit" => {
110 println!("\nš Goodbye!");
111 break;
112 }
113 "summary" => {
114 println!("\nš Session Summary:");
115 println!("{}", agent.get_session_summary());
116 continue;
117 }
118 "memory" => {
119 println!("\nš§ Session Memory:");
120 if let Some(start) = agent.get_memory("session_start") {
121 println!(" Session started: {}", start);
122 }
123 if let Some(dir) = agent.get_memory("working_directory") {
124 println!(" Working directory: {}", dir);
125 }
126 if let Some(files) = agent.get_memory("files_accessed") {
127 println!(" Files accessed: {}", files);
128 }
129 if let Some(edits) = agent.get_memory("edits_made") {
130 println!(" Edits made: {}", edits);
131 }
132 if let Some(action) = agent.get_memory("last_action") {
133 println!(" Last action: {}", action);
134 }
135 continue;
136 }
137 "help" => {
138 println!("\nš Available Commands:");
139 println!(" exit, quit - Exit the demo");
140 println!(" summary - Show session summary");
141 println!(" memory - Show session memory");
142 println!(" help - Show this help");
143 println!("\nš” Try asking the agent to:");
144 println!(" ⢠Search for specific files");
145 println!(" ⢠Read file contents");
146 println!(" ⢠Summarize what it has done");
147 continue;
148 }
149 _ => {}
150 }
151
152 print!("\nAgent: ");
154 io::stdout().flush()?;
155
156 match agent.chat(input).await {
157 Ok(response) => {
158 println!("{}", response);
159
160 agent.increment_counter("files_accessed");
162 }
163 Err(e) => {
164 eprintln!("\nā Error: {}", e);
165 }
166 }
167 }
168
169 println!("\nš Final Session Summary:");
171 println!("{}", agent.get_session_summary());
172
173 println!("\nā
Demo completed successfully!");
174 println!("\nš” Features Demonstrated:");
175 println!(" ā Streaming responses (local/remote models)");
176 println!(" ā File search with pattern matching");
177 println!(" ā File reading with summaries");
178 println!(" ā Session memory tracking");
179 println!(" ā Interactive conversation");
180 println!(" ā Real-time progress updates");
181
182 Ok(())
183}