Skip to main content

tiny_agent_rs/
lib.rs

1//! tiny-agent-rs: A lightweight, type-safe Rust agent library for LLM tool calling
2//!
3//! This library provides a simple, clean interface for building agents that can
4//! execute tools based on LLM responses, with strong typing and deterministic error handling.
5//!
6//! # Quick Start
7//!
8//! ```rust,no_run
9//! use tiny_agent_rs::{Agent, FunctionFactory, tools::CalculatorTool};
10//!
11//! #[tokio::main]
12//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
13//!     let api_key = std::env::var("OPENAI_API_KEY")?;
14//!     let mut function_factory = FunctionFactory::new();
15//!     function_factory.register_tool(CalculatorTool::new());
16//!     
17//!     let agent = Agent::new(api_key, function_factory);
18//!
19//!     let response = agent.run("What is 2 + 3?").await?;
20//!     println!("{}", response);
21//!     Ok(())
22//! }
23//! ```
24
25extern crate self as tiny_agent_rs;
26
27pub mod core;
28pub mod error;
29pub mod schemas;
30pub(crate) mod services;
31pub mod tools;
32pub mod types;
33
34pub use core::{
35    generate_planning_prompt, generate_tool_planning_prompt, get_tool_names, is_planning_response,
36    Agent, AgentMemory, AgentStep, RunResult, TokenUsage, ToolCall, ToolExecution, ToolOutput,
37};
38pub use error::{AgentError, Result};
39pub use schemas::validator::Validator;
40pub use schemas::{schema_type_name, CompletionSchema, SchemaHandle};
41pub use tinyagent_macros::{completion_schema, tool};
42pub use tools::{FunctionFactory, Tool};
43pub use types::response::{deserialize_structured_response, StructuredPayload};
44
45pub use core as agent;
46pub use schemas as schema;
47pub use schemas::validator;
48pub use types::response;
49pub use types::vacation_types;
50
51#[cfg(feature = "cli")]
52pub mod cli;