Complete API documentation for the Helios framework.
Agent system for creating and managing LLM agents.
The main agent struct.
pub struct Agent {
// Private fields
}Methods:
pub fn builder(name: impl Into<String>) -> AgentBuilderCreate an agent builder for flexible configuration.
pub async fn chat(&mut self, message: impl Into<String>) -> Result<String>Send a message to the agent and receive a response.
Example:
let response = agent.chat("Hello!").await?;pub fn register_tool(&mut self, tool: Box<dyn Tool>)Register a tool with the agent.
pub fn clear_history(&mut self)Clear the conversation history.
pub fn set_system_prompt(&mut self, prompt: impl Into<String>)Set or update the system prompt.
pub fn set_max_iterations(&mut self, max: usize)Set the maximum number of tool call iterations.
Builder for creating agents.
pub struct AgentBuilder {
// Private fields
}Methods:
pub fn new(name: impl Into<String>) -> Selfpub fn config(self, config: Config) -> SelfSet the configuration.
pub fn system_prompt(self, prompt: impl Into<String>) -> SelfSet the system prompt.
pub fn tool(self, tool: Box<dyn Tool>) -> SelfAdd a tool to the agent.
pub fn max_iterations(self, max: usize) -> SelfSet maximum tool call iterations.
pub fn build(self) -> Result<Agent>Build the agent.
Example:
let agent = Agent::builder("MyAgent")
.config(config)
.system_prompt("You are helpful")
.tool(Box::new(CalculatorTool))
.max_iterations(5)
.build()
.await?;Configuration management.
Main configuration struct.
pub struct Config {
pub llm: LLMConfig,
}Methods:
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self>Load configuration from a TOML file.
pub fn default() -> SelfCreate a default configuration.
pub fn save<P: AsRef<Path>>(&self, path: P) -> Result<()>Save configuration to a file.
LLM-specific configuration.
pub struct LLMConfig {
pub model_name: String,
pub base_url: String,
pub api_key: String,
pub temperature: f32,
pub max_tokens: u32,
}LLM client and provider traits.
HTTP client for LLM APIs.
pub struct LLMClient {
// Private fields
}Methods:
pub fn new(config: LLMConfig) -> Selfpub async fn chat(
&self,
messages: Vec<ChatMessage>,
tools: Option<Vec<ToolDefinition>>,
) -> Result<ChatMessage>Trait for LLM providers.
#[async_trait]
pub trait LLMProvider: Send + Sync {
async fn generate(&self, request: LLMRequest) -> Result<LLMResponse>;
}Tool system and registry.
Trait for implementing tools.
#[async_trait]
pub trait Tool: Send + Sync {
fn name(&self) -> &str;
fn description(&self) -> &str;
fn parameters(&self) -> HashMap<String, ToolParameter>;
async fn execute(&self, args: Value) -> Result<ToolResult>;
}Example Implementation:
use async_trait::async_trait;
use helios_engine::{Tool, ToolParameter, ToolResult};
struct MyTool;
#[async_trait]
impl Tool for MyTool {
fn name(&self) -> &str {
"my_tool"
}
fn description(&self) -> &str {
"Does something useful"
}
fn parameters(&self) -> HashMap<String, ToolParameter> {
let mut params = HashMap::new();
params.insert(
"input".to_string(),
ToolParameter {
param_type: "string".to_string(),
description: "Input parameter".to_string(),
required: Some(true),
},
);
params
}
async fn execute(&self, args: Value) -> Result<ToolResult> {
let input = args["input"].as_str().unwrap_or("");
Ok(ToolResult::success(format!("Processed: {}", input)))
}
}Registry for managing tools.
pub struct ToolRegistry {
// Private fields
}Methods:
pub fn new() -> Selfpub fn register(&mut self, tool: Box<dyn Tool>)pub async fn execute(&self, name: &str, args: Value) -> Result<ToolResult>pub fn get_definitions(&self) -> Vec<ToolDefinition>pub fn list_tools(&self) -> Vec<String>Result of tool execution.
pub struct ToolResult {
pub success: bool,
pub output: String,
}Methods:
pub fn success(output: impl Into<String>) -> Selfpub fn error(message: impl Into<String>) -> SelfTool parameter definition.
pub struct ToolParameter {
pub param_type: String,
pub description: String,
pub required: Option<bool>,
}Chat message and session types.
A single chat message.
pub struct ChatMessage {
pub role: Role,
pub content: String,
pub name: Option<String>,
pub tool_calls: Option<Vec<ToolCall>>,
pub tool_call_id: Option<String>,
}Methods:
pub fn system(content: impl Into<String>) -> Selfpub fn user(content: impl Into<String>) -> Selfpub fn assistant(content: impl Into<String>) -> Selfpub fn tool(content: impl Into<String>, tool_call_id: impl Into<String>) -> SelfMessage role enum.
pub enum Role {
System,
User,
Assistant,
Tool,
}Manages conversation history.
pub struct ChatSession {
pub messages: Vec<ChatMessage>,
pub system_prompt: Option<String>,
}Methods:
pub fn new() -> Selfpub fn with_system_prompt(self, prompt: impl Into<String>) -> Selfpub fn add_message(&mut self, message: ChatMessage)pub fn add_user_message(&mut self, content: impl Into<String>)pub fn add_assistant_message(&mut self, content: impl Into<String>)pub fn get_messages(&self) -> Vec<ChatMessage>pub fn clear(&mut self)Error types and Result alias.
Main error enum.
pub enum HeliosError {
ConfigError(String),
LLMError(String),
ToolError(String),
AgentError(String),
NetworkError(reqwest::Error),
SerializationError(serde_json::Error),
IoError(std::io::Error),
TomlError(toml::de::Error),
}Type alias for std::result::Result<T, HeliosError>.
pub type Result<T> = std::result::Result<T, HeliosError>;Performs basic arithmetic operations.
pub struct CalculatorTool;Parameters:
expression(string, required): Mathematical expression
Example:
use helios_engine::CalculatorTool;
let mut agent = Agent::builder("MathBot")
.config(config)
.tool(Box::new(CalculatorTool))
.build()
.await?;Echoes back a message.
pub struct EchoTool;Parameters:
message(string, required): Message to echo
Example:
use helios_engine::EchoTool;
let mut agent = Agent::builder("EchoBot")
.config(config)
.tool(Box::new(EchoTool))
.build()
.await?;use helios_engine::{Agent, Config};
let config = Config::from_file("config.toml")?;
let mut agent = Agent::builder("Assistant")
.config(config)
.system_prompt("You are helpful")
.build()
.await?;
let response = agent.chat("Hello").await?;use helios_engine::{Agent, Config, CalculatorTool};
let config = Config::from_file("config.toml")?;
let mut agent = Agent::builder("MathBot")
.config(config)
.tool(Box::new(CalculatorTool))
.build()
.await?;
let response = agent.chat("What is 10 * 5?").await?;use async_trait::async_trait;
use helios_engine::{Tool, ToolParameter, ToolResult};
struct CustomTool;
#[async_trait]
impl Tool for CustomTool {
fn name(&self) -> &str { "custom" }
fn description(&self) -> &str { "Custom tool" }
fn parameters(&self) -> HashMap<String, ToolParameter> {
HashMap::new()
}
async fn execute(&self, _args: Value) -> helios::Result<ToolResult> {
Ok(ToolResult::success("Done!"))
}
}helios
├── Agent
│ ├── LLMClient
│ ├── ToolRegistry
│ └── ChatSession
├── Config
│ └── LLMConfig
├── Tool (trait)
│ ├── CalculatorTool
│ ├── EchoTool
│ └── [Your Custom Tools]
└── Error
└── HeliosError
For more examples, see the examples directory.