ultra_simple/
ultra_simple.rs

1//! # Ultra Simple Example
2//!
3//! This example shows the absolute EASIEST way to use Helios Engine.
4//! Just a few lines to create an agent and chat!
5
6use helios_engine::{Agent, CalculatorTool, Config};
7
8#[tokio::main]
9async fn main() -> helios_engine::Result<()> {
10    println!("🚀 Ultra Simple Helios Example\n");
11
12    // ========== SIMPLEST AGENT CREATION ==========
13    println!("1️⃣  Creating an agent - shortest possible syntax:\n");
14
15    // One-liner: Create agent with auto config
16    let mut agent = Agent::builder("Helper")
17        .auto_config()
18        .prompt("You are helpful and concise.")
19        .build()
20        .await?;
21
22    println!("✓ Agent created!\n");
23
24    // ========== SIMPLEST CHAT ==========
25    println!("2️⃣  Asking questions - simplest possible:\n");
26
27    // Use .ask() instead of .chat() for more natural syntax
28    let answer = agent.ask("What is 2+2?").await?;
29    println!("Q: What is 2+2?\nA: {}\n", answer);
30
31    // ========== SIMPLEST CONFIG ==========
32    println!("3️⃣  Creating config with shortest syntax:\n");
33
34    // Ultra-short config creation
35    let _config = Config::builder()
36        .m("gpt-4") // .m() is shorthand for .model()
37        .key("your-api-key") // .key() is shorthand for .api_key()
38        .temp(0.8) // .temp() is shorthand for .temperature()
39        .tokens(1024) // .tokens() is shorthand for .max_tokens()
40        .build();
41
42    println!("✓ Config created with ultra-short syntax!\n");
43
44    // ========== SIMPLEST AGENT WITH TOOLS ==========
45    println!("4️⃣  Agent with tools - simplest way:\n");
46
47    let mut calc_agent = Agent::builder("Calculator")
48        .auto_config()
49        .prompt("You are a math expert.")
50        .with_tool(Box::new(CalculatorTool)) // Add single tool
51        .build()
52        .await?;
53
54    let result = calc_agent.ask("Calculate 15 * 7 + 5").await?;
55    println!("Q: Calculate 15 * 7 + 5\nA: {}\n", result);
56
57    // ========== SIMPLEST QUICK AGENT ==========
58    println!("5️⃣  Quick agent - one method call:\n");
59
60    // Agent::quick() creates agent in ONE LINE with auto config!
61    let mut quick_agent = Agent::quick("QuickBot").await?;
62    let quick_answer = quick_agent.ask("Say hello!").await?;
63    println!("Response: {}\n", quick_answer);
64
65    // ========== SIMPLEST CHAT MESSAGES ==========
66    println!("6️⃣  Creating messages - super short syntax:\n");
67
68    use helios_engine::ChatMessage;
69
70    // Short aliases for message creation
71    let _sys_msg = ChatMessage::sys("You are helpful"); // .sys() not .system()
72    let _user_msg = ChatMessage::msg("Hello there"); // .msg() not .user()
73    let _reply_msg = ChatMessage::reply("Hi! How can I help?"); // .reply() not .assistant()
74
75    println!("✓ Messages created with ultra-short syntax!\n");
76
77    // ========== SHORTEST AUTOFOREST ==========
78    println!("7️⃣  AutoForest - simplest multi-agent orchestration:\n");
79
80    use helios_engine::AutoForest;
81
82    let mut forest = AutoForest::new(Config::builder().m("gpt-4").build())
83        .with_tools(vec![Box::new(CalculatorTool)])
84        .build()
85        .await?;
86
87    // Use .run() for shortest syntax
88    let forest_result = forest.run("Analyze these numbers: 10, 20, 30, 40").await?;
89    println!("Forest Result:\n{}\n", forest_result);
90
91    // ========== COMPARISON TABLE ==========
92    println!("📊 Syntax Comparison - Short vs Long:\n");
93    println!("┌─────────────────────┬──────────────────────┬─────────────────┐");
94    println!("│ Operation           │ Short Syntax         │ Long Syntax      │");
95    println!("├─────────────────────┼──────────────────────┼─────────────────┤");
96    println!("│ Create Agent        │ Agent::quick()       │ Agent::builder()│");
97    println!("│ Ask Question        │ .ask()               │ .chat()          │");
98    println!("│ System Prompt       │ .prompt()            │ .system_prompt() │");
99    println!("│ Config Model        │ .m()                 │ .model()         │");
100    println!("│ Config Key          │ .key()               │ .api_key()       │");
101    println!("│ Config Temp         │ .temp()              │ .temperature()   │");
102    println!("│ Config Tokens       │ .tokens()            │ .max_tokens()    │");
103    println!("│ System Message      │ ChatMessage::sys()   │ ChatMessage::system()");
104    println!("│ User Message        │ ChatMessage::msg()   │ ChatMessage::user()");
105    println!("│ Assistant Message   │ ChatMessage::reply() │ ChatMessage::assistant()");
106    println!("│ AutoForest Execute  │ .run()               │ .execute_task()  │");
107    println!("└─────────────────────┴──────────────────────┴─────────────────┘\n");
108
109    println!("✅ All examples completed!");
110    println!("💡 Tip: Mix and match short and long syntax based on your preference!");
111
112    Ok(())
113}