YART
YART (Yet Another Rig Tool) is a Rust library for creating tools with the rig::tool::Tool trait, providing a convenient procedural macro (#[rig_tool]) to generate tool implementations with JSON schema support. It re-exports the #[rig_tool] macro from yart_macro and shared types/utilities from yart_shared, offering a unified API for the rig framework.
Purpose
The yart crate is the primary entry point for using YART. It simplifies integration by combining the procedural macro and shared utilities into a single dependency, enabling developers to define async tools with minimal boilerplate.
Features
- Procedural Macro: The
#[rig_tool]macro generatesrig::tool::Toolimplementations for async functions with 0-2 arguments (optional context, optional args). - JSON Schema Support: Automatically generates JSON schemas for tool arguments using
schemars. - Shared Utilities: Provides
ToolError,ToolOutput, andderive_parametersfor consistent error handling and output serialization. - Async Support: Wraps async functions with
Resultreturns, handling errors viaToolError. - Unified API: Import all functionality with
use yart::*.
Installation
Add yart to your project’s Cargo.toml:
[]
= "0.1.1"
Usage
Use the #[rig_tool] macro to define tools, specifying a description and optional name. The macro generates a struct implementing rig::tool::Tool with methods for instantiation, naming, schema definition, and execution.
Example
use Arc;
use ;
use ;
use JsonSchema;
// Define argument type
// Define output type
// Tool without context
async
// Tool with context
async
async
Dependencies
The yart crate re-exports functionality from:
yart-macro: Provides the#[rig_tool]macro for generating tool implementations.yart-shared: Supplies shared types (ToolError,ToolOutput) and utilities (derive_parameters).
You only need to depend on yart in your Cargo.toml, as it includes both yart_macro and yart_shared.
Documentation
- Crates.io: yart
- Repository: github.com/pupplecat/yart
- API Docs: docs.rs/yart
Contributing
Contributions are welcome! Please submit pull requests or open issues on the project repository.
License
MIT