Expand description
§Tools-rs: A Tool Collection and Execution Framework
Tools-rs provides a framework for building, registering, and executing tools with automatic JSON schema generation for LLM integration.
§Quick Start
use tools_rs::{tool, collect_tools, call_tool_with_args};
#[tool]
/// Adds two numbers together
async fn add(a: i32, b: i32) -> i32 {
a + b
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let tools = collect_tools();
let result = call_tool_with_args(&tools, "add", &[1, 2]).await?;
println!("Result: {}", result);
Ok(())
}§Features
- Automatic Registration: Use
#[tool]to automatically register functions - JSON Schema Generation: Automatic schema generation for LLM integration
- Type Safety: Full type safety with JSON serialization at boundaries
- Async Support: Built for async/await from the ground up
- Error Handling: Comprehensive error types with context
§Manual Registration
use tools_rs::ToolCollection;
let mut tools = ToolCollection::new();
tools.register("greet", "Greets a person", |name: String| async move {
format!("Hello, {}!", name)
})?;Modules§
- prelude
- Convenient imports for common usage patterns.
Structs§
- Deserialization
Error - Specific deserialization errors
- Function
Call - Represents a function call with name and arguments
- Function
Decl - Function declaration for LLM consumption
- Tool
Collection - Tool
Metadata - Metadata about a tool function
- Tool
Registration - Tool registration for inventory collection
- Type
Signature - Runtime type signature information
Enums§
- Tool
Error - Errors that can occur during tool operations
Traits§
- Tool
Schema - Trait for types that can generate a JSON Schema representation of themselves.
Functions§
- call_
tool - Call a tool by name with JSON arguments.
- call_
tool_ by_ name - Call a tool by name with JSON arguments on a given collection.
- call_
tool_ with - Call a tool by name with typed arguments.
- call_
tool_ with_ args - Call a tool by name with typed arguments on a given collection.
- collect_
tools - Collect all tools registered via the
#[tool]macro. - function_
declarations - Generate function declarations in JSON format for LLM consumption.
- list_
tool_ names - List all available tool names in a collection.