basic_chat/
basic_chat.rs

1//! # Example: Basic Chat with Real-Time Streaming
2//!
3//! This example demonstrates the simplest way to use the Helios Engine: a basic chat
4//! with an agent. The agent maintains a conversation history and can respond to
5//! multiple turns of conversation.
6//!
7//! **NEW**: Streaming is now enabled by default! Watch as responses appear token-by-token
8//! in real-time, just like ChatGPT's interface.
9
10use helios_engine::{Agent, Config};
11use std::io::{self, Write};
12
13#[tokio::main]
14async fn main() -> helios_engine::Result<()> {
15    println!("šŸš€ Helios Engine - Basic Chat Example");
16    println!("=====================================");
17    println!("šŸ’” Streaming is enabled by default - watch tokens appear in real-time!\n");
18
19    // Load configuration from `config.toml`.
20    let config = Config::from_file("config.toml")?;
21
22    // Create a simple agent named "BasicAgent".
23    let mut agent = Agent::builder("BasicAgent")
24        .config(config)
25        .system_prompt("You are a helpful assistant.")
26        .build()
27        .await?;
28
29    // --- Send a message to the agent ---
30    println!("User: Hello! How are you?");
31    print!("Agent (streaming): ");
32    io::stdout().flush()?;
33
34    let _response = agent.chat("Hello! How are you?").await?;
35    println!();
36
37    // --- Continue the conversation ---
38    println!("\nUser: What can you help me with?");
39    print!("Agent (streaming): ");
40    io::stdout().flush()?;
41
42    let _response = agent.chat("What can you help me with?").await?;
43    println!();
44
45    println!("\nāœ… Demo completed! Notice how responses streamed in real-time.");
46
47    Ok(())
48}