Expand description
tiny-agent-rs: A lightweight, type-safe Rust agent library for LLM tool calling
This library provides a simple, clean interface for building agents that can execute tools based on LLM responses, with strong typing and deterministic error handling.
§Quick Start
use tiny_agent_rs::{Agent, FunctionFactory, tools::CalculatorTool};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("OPENAI_API_KEY")?;
let mut function_factory = FunctionFactory::new();
function_factory.register_tool(CalculatorTool::new());
let agent = Agent::new(api_key, function_factory);
let response = agent.run("What is 2 + 3?").await?;
println!("{}", response);
Ok(())
}Re-exports§
pub use core::generate_planning_prompt;pub use core::generate_tool_planning_prompt;pub use core::get_tool_names;pub use core::is_planning_response;pub use core::Agent;pub use core::AgentMemory;pub use core::AgentStep;pub use core::RunResult;pub use core::TokenUsage;pub use core::ToolCall;pub use core::ToolExecution;pub use core::ToolOutput;pub use error::AgentError;pub use error::Result;pub use schemas::validator::Validator;pub use schemas::schema_type_name;pub use schemas::CompletionSchema;pub use schemas::SchemaHandle;pub use tools::FunctionFactory;pub use tools::Tool;pub use types::response::deserialize_structured_response;pub use types::response::StructuredPayload;pub use core as agent;pub use schemas as schema;pub use schemas::validator;pub use types::response;pub use types::vacation_types;
Modules§
Macros§
- tool
- Defines the
tool!macro for declaring tools. Generates aToolimpl with JSON Schema fromparamsand wires an async closure as the executor.