pub struct ConfigBuilder { /* private fields */ }Expand description
A builder for creating configurations with a fluent API.
ImplementationsΒ§
SourceΒ§impl ConfigBuilder
impl ConfigBuilder
Sourcepub fn m(self, model: impl Into<String>) -> Self
pub fn m(self, model: impl Into<String>) -> Self
Shorthand: set model with βmβ
Examples found in repository?
examples/ultra_simple.rs (line 36)
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}Sourcepub fn key(self, key: impl Into<String>) -> Self
pub fn key(self, key: impl Into<String>) -> Self
Shorthand: set API key with βkeyβ
Examples found in repository?
examples/ultra_simple.rs (line 37)
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}Sourcepub fn temperature(self, temp: f32) -> Self
pub fn temperature(self, temp: f32) -> Self
Sets the temperature for generation.
Examples found in repository?
examples/auto_forest_demo.rs (line 21)
15async fn main() -> helios_engine::Result<()> {
16 println!("π² AutoForest - Intelligent Agent Orchestration Demo\n");
17 println!("====================================================\n");
18
19 // Step 1: Load or create configuration
20 println!("π Creating configuration...");
21 let config = Config::builder().temperature(0.7).max_tokens(2048).build();
22 println!("β Configuration ready\n");
23
24 // Step 2: Create AutoForest with available tools
25 println!("π§ Initializing AutoForest with tools...");
26 let mut auto_forest = AutoForest::new(config)
27 .with_tools(vec![
28 Box::new(CalculatorTool),
29 // Additional tools could be added here
30 ])
31 .build()
32 .await?;
33 println!("β AutoForest initialized\n");
34
35 // Step 3: Define a complex task
36 let task = r#"
37 I need to analyze a business problem:
38 1. A company has Q3 revenue data showing mixed results across 5 product categories
39 2. I need to understand which categories are underperforming
40 3. Calculate the performance metrics for each category
41 4. Identify trends and predict Q4 performance
42 5. Recommend which categories need attention
43 "#;
44
45 println!("π Submitting task to AutoForest...");
46 println!("Task: {}\n", task.trim());
47
48 // Step 4: Execute the task
49 println!("π AutoForest is orchestrating agent deployment...\n");
50 let result = auto_forest.execute_task(task).await?;
51
52 // Step 5: Display the orchestration plan
53 println!("π Orchestration Plan Generated:");
54 println!("================================\n");
55
56 if let Some(plan) = auto_forest.orchestration_plan() {
57 println!("Task: {}", plan.task.trim());
58 println!("Number of Agents Spawned: {}", plan.num_agents);
59 println!("Planning Reasoning: {}\n", plan.reasoning);
60
61 println!("Agent Configurations:");
62 println!("-----------------");
63 for (i, agent_config) in plan.agents.iter().enumerate() {
64 println!(
65 "Agent {}: {} ({})",
66 i + 1,
67 agent_config.name,
68 agent_config.role
69 );
70 println!(" Prompt: {}", agent_config.system_prompt);
71 if !agent_config.tool_indices.is_empty() {
72 println!(" Tools: {:?}", agent_config.tool_indices);
73 }
74 println!();
75 }
76
77 println!("Task Breakdown:");
78 println!("--------------");
79 for (agent_name, subtask) in &plan.task_breakdown {
80 println!("β’ {} β {}", agent_name, subtask);
81 }
82 println!();
83 }
84
85 // Step 6: Display spawned agents
86 println!("π€ Spawned Agents:");
87 println!("-----------------");
88 let spawned = auto_forest.spawned_agents();
89 println!("Total agents created: {}\n", spawned.len());
90
91 for (i, spawned_agent) in spawned.iter().enumerate() {
92 println!("Agent {}: {}", i + 1, spawned_agent.config.name);
93 println!(" Role: {}", spawned_agent.config.role);
94 if let Some(result) = &spawned_agent.result {
95 println!(" Result available: Yes ({} chars)", result.len());
96 } else {
97 println!(" Result: Pending");
98 }
99 println!();
100 }
101
102 // Step 7: Display the final synthesized result
103 println!("π Final Synthesized Result:");
104 println!("==========================\n");
105 println!("{}\n", result);
106
107 // Step 8: Demonstrate a second task with different complexity
108 println!("\nπ Executing a second task with different complexity...\n");
109
110 let simple_task = "Calculate the average of these numbers: 100, 200, 300, 400, 500. Then tell me what percentage each is of the total.";
111
112 println!("Task: {}\n", simple_task);
113 println!("π Processing...\n");
114
115 let result2 = auto_forest.execute_task(simple_task).await?;
116
117 println!("Result:\n{}\n", result2);
118
119 if let Some(plan) = auto_forest.orchestration_plan() {
120 println!(
121 "This task resulted in {} agent(s) - a simpler orchestration plan.",
122 plan.num_agents
123 );
124 println!("Reasoning: {}\n", plan.reasoning);
125 }
126
127 println!("β
AutoForest demo completed!");
128 println!("=============================");
129 println!("\nπ‘ Key Features Demonstrated:");
130 println!(" β’ Automatic agent spawning based on task complexity");
131 println!(" β’ Specialized agent prompt generation");
132 println!(" β’ Task breakdown across agents");
133 println!(" β’ Result aggregation and synthesis");
134 println!(" β’ Flexible orchestration for varying task complexity");
135
136 Ok(())
137}Sourcepub fn temp(self, temp: f32) -> Self
pub fn temp(self, temp: f32) -> Self
Shorthand: set temperature with βtempβ
Examples found in repository?
examples/ultra_simple.rs (line 38)
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}Sourcepub fn max_tokens(self, tokens: u32) -> Self
pub fn max_tokens(self, tokens: u32) -> Self
Sets the maximum tokens for generation.
Examples found in repository?
examples/auto_forest_demo.rs (line 21)
15async fn main() -> helios_engine::Result<()> {
16 println!("π² AutoForest - Intelligent Agent Orchestration Demo\n");
17 println!("====================================================\n");
18
19 // Step 1: Load or create configuration
20 println!("π Creating configuration...");
21 let config = Config::builder().temperature(0.7).max_tokens(2048).build();
22 println!("β Configuration ready\n");
23
24 // Step 2: Create AutoForest with available tools
25 println!("π§ Initializing AutoForest with tools...");
26 let mut auto_forest = AutoForest::new(config)
27 .with_tools(vec![
28 Box::new(CalculatorTool),
29 // Additional tools could be added here
30 ])
31 .build()
32 .await?;
33 println!("β AutoForest initialized\n");
34
35 // Step 3: Define a complex task
36 let task = r#"
37 I need to analyze a business problem:
38 1. A company has Q3 revenue data showing mixed results across 5 product categories
39 2. I need to understand which categories are underperforming
40 3. Calculate the performance metrics for each category
41 4. Identify trends and predict Q4 performance
42 5. Recommend which categories need attention
43 "#;
44
45 println!("π Submitting task to AutoForest...");
46 println!("Task: {}\n", task.trim());
47
48 // Step 4: Execute the task
49 println!("π AutoForest is orchestrating agent deployment...\n");
50 let result = auto_forest.execute_task(task).await?;
51
52 // Step 5: Display the orchestration plan
53 println!("π Orchestration Plan Generated:");
54 println!("================================\n");
55
56 if let Some(plan) = auto_forest.orchestration_plan() {
57 println!("Task: {}", plan.task.trim());
58 println!("Number of Agents Spawned: {}", plan.num_agents);
59 println!("Planning Reasoning: {}\n", plan.reasoning);
60
61 println!("Agent Configurations:");
62 println!("-----------------");
63 for (i, agent_config) in plan.agents.iter().enumerate() {
64 println!(
65 "Agent {}: {} ({})",
66 i + 1,
67 agent_config.name,
68 agent_config.role
69 );
70 println!(" Prompt: {}", agent_config.system_prompt);
71 if !agent_config.tool_indices.is_empty() {
72 println!(" Tools: {:?}", agent_config.tool_indices);
73 }
74 println!();
75 }
76
77 println!("Task Breakdown:");
78 println!("--------------");
79 for (agent_name, subtask) in &plan.task_breakdown {
80 println!("β’ {} β {}", agent_name, subtask);
81 }
82 println!();
83 }
84
85 // Step 6: Display spawned agents
86 println!("π€ Spawned Agents:");
87 println!("-----------------");
88 let spawned = auto_forest.spawned_agents();
89 println!("Total agents created: {}\n", spawned.len());
90
91 for (i, spawned_agent) in spawned.iter().enumerate() {
92 println!("Agent {}: {}", i + 1, spawned_agent.config.name);
93 println!(" Role: {}", spawned_agent.config.role);
94 if let Some(result) = &spawned_agent.result {
95 println!(" Result available: Yes ({} chars)", result.len());
96 } else {
97 println!(" Result: Pending");
98 }
99 println!();
100 }
101
102 // Step 7: Display the final synthesized result
103 println!("π Final Synthesized Result:");
104 println!("==========================\n");
105 println!("{}\n", result);
106
107 // Step 8: Demonstrate a second task with different complexity
108 println!("\nπ Executing a second task with different complexity...\n");
109
110 let simple_task = "Calculate the average of these numbers: 100, 200, 300, 400, 500. Then tell me what percentage each is of the total.";
111
112 println!("Task: {}\n", simple_task);
113 println!("π Processing...\n");
114
115 let result2 = auto_forest.execute_task(simple_task).await?;
116
117 println!("Result:\n{}\n", result2);
118
119 if let Some(plan) = auto_forest.orchestration_plan() {
120 println!(
121 "This task resulted in {} agent(s) - a simpler orchestration plan.",
122 plan.num_agents
123 );
124 println!("Reasoning: {}\n", plan.reasoning);
125 }
126
127 println!("β
AutoForest demo completed!");
128 println!("=============================");
129 println!("\nπ‘ Key Features Demonstrated:");
130 println!(" β’ Automatic agent spawning based on task complexity");
131 println!(" β’ Specialized agent prompt generation");
132 println!(" β’ Task breakdown across agents");
133 println!(" β’ Result aggregation and synthesis");
134 println!(" β’ Flexible orchestration for varying task complexity");
135
136 Ok(())
137}Sourcepub fn tokens(self, tokens: u32) -> Self
pub fn tokens(self, tokens: u32) -> Self
Shorthand: set max tokens with βtokensβ
Examples found in repository?
examples/ultra_simple.rs (line 39)
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}Sourcepub fn build(self) -> Config
pub fn build(self) -> Config
Builds the configuration.
Examples found in repository?
examples/auto_forest_demo.rs (line 21)
15async fn main() -> helios_engine::Result<()> {
16 println!("π² AutoForest - Intelligent Agent Orchestration Demo\n");
17 println!("====================================================\n");
18
19 // Step 1: Load or create configuration
20 println!("π Creating configuration...");
21 let config = Config::builder().temperature(0.7).max_tokens(2048).build();
22 println!("β Configuration ready\n");
23
24 // Step 2: Create AutoForest with available tools
25 println!("π§ Initializing AutoForest with tools...");
26 let mut auto_forest = AutoForest::new(config)
27 .with_tools(vec![
28 Box::new(CalculatorTool),
29 // Additional tools could be added here
30 ])
31 .build()
32 .await?;
33 println!("β AutoForest initialized\n");
34
35 // Step 3: Define a complex task
36 let task = r#"
37 I need to analyze a business problem:
38 1. A company has Q3 revenue data showing mixed results across 5 product categories
39 2. I need to understand which categories are underperforming
40 3. Calculate the performance metrics for each category
41 4. Identify trends and predict Q4 performance
42 5. Recommend which categories need attention
43 "#;
44
45 println!("π Submitting task to AutoForest...");
46 println!("Task: {}\n", task.trim());
47
48 // Step 4: Execute the task
49 println!("π AutoForest is orchestrating agent deployment...\n");
50 let result = auto_forest.execute_task(task).await?;
51
52 // Step 5: Display the orchestration plan
53 println!("π Orchestration Plan Generated:");
54 println!("================================\n");
55
56 if let Some(plan) = auto_forest.orchestration_plan() {
57 println!("Task: {}", plan.task.trim());
58 println!("Number of Agents Spawned: {}", plan.num_agents);
59 println!("Planning Reasoning: {}\n", plan.reasoning);
60
61 println!("Agent Configurations:");
62 println!("-----------------");
63 for (i, agent_config) in plan.agents.iter().enumerate() {
64 println!(
65 "Agent {}: {} ({})",
66 i + 1,
67 agent_config.name,
68 agent_config.role
69 );
70 println!(" Prompt: {}", agent_config.system_prompt);
71 if !agent_config.tool_indices.is_empty() {
72 println!(" Tools: {:?}", agent_config.tool_indices);
73 }
74 println!();
75 }
76
77 println!("Task Breakdown:");
78 println!("--------------");
79 for (agent_name, subtask) in &plan.task_breakdown {
80 println!("β’ {} β {}", agent_name, subtask);
81 }
82 println!();
83 }
84
85 // Step 6: Display spawned agents
86 println!("π€ Spawned Agents:");
87 println!("-----------------");
88 let spawned = auto_forest.spawned_agents();
89 println!("Total agents created: {}\n", spawned.len());
90
91 for (i, spawned_agent) in spawned.iter().enumerate() {
92 println!("Agent {}: {}", i + 1, spawned_agent.config.name);
93 println!(" Role: {}", spawned_agent.config.role);
94 if let Some(result) = &spawned_agent.result {
95 println!(" Result available: Yes ({} chars)", result.len());
96 } else {
97 println!(" Result: Pending");
98 }
99 println!();
100 }
101
102 // Step 7: Display the final synthesized result
103 println!("π Final Synthesized Result:");
104 println!("==========================\n");
105 println!("{}\n", result);
106
107 // Step 8: Demonstrate a second task with different complexity
108 println!("\nπ Executing a second task with different complexity...\n");
109
110 let simple_task = "Calculate the average of these numbers: 100, 200, 300, 400, 500. Then tell me what percentage each is of the total.";
111
112 println!("Task: {}\n", simple_task);
113 println!("π Processing...\n");
114
115 let result2 = auto_forest.execute_task(simple_task).await?;
116
117 println!("Result:\n{}\n", result2);
118
119 if let Some(plan) = auto_forest.orchestration_plan() {
120 println!(
121 "This task resulted in {} agent(s) - a simpler orchestration plan.",
122 plan.num_agents
123 );
124 println!("Reasoning: {}\n", plan.reasoning);
125 }
126
127 println!("β
AutoForest demo completed!");
128 println!("=============================");
129 println!("\nπ‘ Key Features Demonstrated:");
130 println!(" β’ Automatic agent spawning based on task complexity");
131 println!(" β’ Specialized agent prompt generation");
132 println!(" β’ Task breakdown across agents");
133 println!(" β’ Result aggregation and synthesis");
134 println!(" β’ Flexible orchestration for varying task complexity");
135
136 Ok(())
137}More examples
examples/ultra_simple.rs (line 40)
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}Trait ImplementationsΒ§
Auto Trait ImplementationsΒ§
impl Freeze for ConfigBuilder
impl RefUnwindSafe for ConfigBuilder
impl Send for ConfigBuilder
impl Sync for ConfigBuilder
impl Unpin for ConfigBuilder
impl UnwindSafe for ConfigBuilder
Blanket ImplementationsΒ§
SourceΒ§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
SourceΒ§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more