helios_engine/
lib.rs

1//! # Helios Engine
2//!
3//! Helios is a powerful and flexible Rust framework for building LLM-powered agents
4//! with tool support, chat capabilities, and easy configuration management.
5//!
6//! ## Quick Start
7//!
8//! ### Using as a Library (Direct LLM Calls)
9//!
10//! ## Example
11//! ```no_run
12//! use helios_engine::{LLMClient, ChatMessage};
13//! use helios_engine::config::LLMConfig;
14//!
15//! #[tokio::main]
16//! async fn main() -> helios_engine::Result<()> {
17//!     let llm_config = LLMConfig {
18//!         model_name: "gpt-3.5-turbo".to_string(),
19//!         base_url: "https://api.openai.com/v1".to_string(),
20//!         api_key: std::env::var("OPENAI_API_KEY").unwrap(),
21//!         temperature: 0.7,
22//!         max_tokens: 2048,
23//!     };
24//!
25//!     let client = LLMClient::new(helios_engine::llm::LLMProviderType::Remote(llm_config)).await?;
26//!     let messages = vec![
27//!         ChatMessage::system("You are a helpful assistant."),
28//!         ChatMessage::user("What is the capital of France?"),
29//!     ];
30//!
31//!     let response = client.chat(messages, None, None, None, None).await?;
32//!     println!("Response: {}", response.content);
33//!     Ok(())
34//! }
35//! ```
36//!
37//! ## Overview
38//!
39//! ```no_run
40//! use helios_engine::{Agent, Config, CalculatorTool};
41//!
42//! #[tokio::main]
43//! async fn main() -> helios_engine::Result<()> {
44//!     let config = Config::from_file("config.toml")?;
45//!
46//!     let mut agent = Agent::builder("MyAgent")
47//!         .config(config)
48//!         .system_prompt("You are a helpful assistant.")
49//!         .tool(Box::new(CalculatorTool))
50//!         .build()
51//!         .await?;
52//!
53//!     let response = agent.chat("What is 15 * 7?").await?;
54//!     println!("Agent: {}", response);
55//!     Ok(())
56//! }
57//! ```
58//!
59//! ## Features
60//!
61//! - **Direct LLM Access**: Use `LLMClient` for simple, direct calls to LLM models.
62//! - **Agent System**: Create intelligent agents with tools and persistent conversation.
63//! - **Tool Support**: Extensible tool system for adding custom functionality.
64//! - **Multi-Provider**: Works with OpenAI, Azure OpenAI, local models, and any OpenAI-compatible API.
65//! - **Type-Safe**: Leverages Rust's type system for reliability.
66//! - **Async**: Built on Tokio for high-performance async operations.
67
68// Modules
69
70/// Defines the `Agent` struct and its associated builder, which are central to the Helios Engine.
71pub mod agent;
72
73/// Provides chat-related functionality, including `ChatMessage`, `ChatSession`, and `Role`.
74pub mod chat;
75
76/// Handles configuration for the engine, including LLM providers and agent settings.
77pub mod config;
78
79/// Defines the custom `HeliosError` and `Result` types for error handling.
80pub mod error;
81
82/// Manages interactions with Large Language Models (LLMs), including different providers.
83pub mod llm;
84
85/// Contains the tool system, including the `Tool` trait and various tool implementations.
86pub mod tools;
87
88/// Simplified tool creation with the builder pattern.
89pub mod tool_builder;
90
91/// Macros for ultra-simple tool creation.
92pub mod tool_macro;
93
94/// Provides HTTP server functionality for exposing OpenAI-compatible API endpoints.
95pub mod serve;
96
97/// Simplified endpoint creation with the builder pattern for custom HTTP endpoints.
98pub mod endpoint_builder;
99
100/// RAG (Retrieval-Augmented Generation) system with vector stores and embeddings.
101pub mod rag;
102
103/// RAG tool implementation for agent use.
104pub mod rag_tool;
105
106/// Forest of Agents - Multi-agent collaboration system.
107pub mod forest;
108
109/// AutoForest - Automatic orchestration of agent forests for complex tasks.
110pub mod auto_forest;
111
112// Re-exports
113
114/// Re-export of the `Agent` and `AgentBuilder` for convenient access.
115pub use agent::{Agent, AgentBuilder};
116
117/// Re-export of chat-related types.
118pub use chat::{ChatMessage, ChatSession, Role};
119
120#[cfg(not(feature = "local"))]
121pub use config::{Config, ConfigBuilder, LLMConfig};
122/// Re-export of configuration types.
123#[cfg(feature = "local")]
124pub use config::{Config, ConfigBuilder, LLMConfig, LocalConfig};
125
126/// Re-export of the custom error and result types.
127pub use error::{HeliosError, Result};
128
129/// Re-export of LLM-related types.
130#[cfg(feature = "local")]
131pub use llm::{
132    Delta, LLMClient, LLMProvider, LLMRequest, LLMResponse, LocalLLMProvider, StreamChoice,
133    StreamChunk,
134};
135#[cfg(not(feature = "local"))]
136pub use llm::{Delta, LLMClient, LLMProvider, LLMRequest, LLMResponse, StreamChoice, StreamChunk};
137pub use tools::{
138    CalculatorTool, EchoTool, FileEditTool, FileIOTool, FileListTool, FileReadTool, FileSearchTool,
139    FileWriteTool, HttpRequestTool, JsonParserTool, MemoryDBTool, QdrantRAGTool, ShellCommandTool,
140    SystemInfoTool, TextProcessorTool, TimestampTool, Tool, ToolParameter, ToolRegistry,
141    ToolResult, WebScraperTool,
142};
143
144/// Re-export of tool builder for simplified tool creation.
145pub use tool_builder::ToolBuilder;
146
147/// Re-export of RAG system components.
148pub use rag::{
149    Document, EmbeddingProvider, InMemoryVectorStore, OpenAIEmbeddings, QdrantVectorStore,
150    RAGSystem, SearchResult, VectorStore,
151};
152
153/// Re-export of RAG tool.
154pub use rag_tool::RAGTool;
155
156/// Re-export of serve functionality.
157pub use serve::{
158    load_custom_endpoints_config, start_server, start_server_with_agent,
159    start_server_with_agent_and_custom_endpoints, start_server_with_custom_endpoints,
160    CustomEndpoint, CustomEndpointsConfig, ServerBuilder, ServerState,
161};
162
163/// Re-export of endpoint builder for simplified custom endpoint creation.
164pub use endpoint_builder::{
165    delete, get, patch, post, put, EndpointBuilder, EndpointRequest, EndpointResponse, HttpMethod,
166};
167
168/// Re-export of Forest of Agents functionality.
169pub use forest::{
170    AgentId, CreatePlanTool, DelegateTaskTool, ForestBuilder, ForestMessage, ForestOfAgents,
171    SendMessageTool, ShareContextTool, SharedContext, TaskItem, TaskPlan, TaskStatus,
172    UpdateTaskMemoryTool,
173};
174
175/// Re-export of AutoForest functionality.
176pub use auto_forest::{
177    AgentConfig, AutoForest, AutoForestBuilder, OrchestrationPlan, SpawnedAgent,
178};