Expand description
§serdes-ai-toolsets
Toolset abstractions for grouping and managing tools.
This crate provides the infrastructure for organizing tools into logical groups with shared configuration, lifecycle management, and composition.
§Core Concepts
AbstractToolset: Base trait for all toolsetsFunctionToolset: Wrap function-based toolsCombinedToolset: Merge multiple toolsetsDynamicToolset: Runtime tool management
§Toolset Wrappers
FilteredToolset: Filter tools by predicatePrefixedToolset: Add name prefixesRenamedToolset: Rename specific toolsPreparedToolset: Runtime tool modificationApprovalRequiredToolset: Require approvalWrapperToolset: Pre/post processing hooksExternalToolset: External tool execution
§Example
use serdes_ai_toolsets::{FunctionToolset, CombinedToolset, PrefixedToolset, AbstractToolset};
use serdes_ai_tools::{Tool, ToolDefinition, RunContext, ToolReturn, ToolError};
use async_trait::async_trait;
struct SearchTool;
#[async_trait]
impl Tool for SearchTool {
fn definition(&self) -> ToolDefinition {
ToolDefinition::new("search", "Search for items")
}
async fn call(&self, _ctx: &RunContext, _args: serde_json::Value) -> Result<ToolReturn, ToolError> {
Ok(ToolReturn::text("results"))
}
}
// Create toolsets
let web_tools = FunctionToolset::new().with_id("web").tool(SearchTool);
let local_tools = FunctionToolset::new().with_id("local").tool(SearchTool);
// Prefix to avoid conflicts
let prefixed_web = PrefixedToolset::new(web_tools, "web");
let prefixed_local = PrefixedToolset::new(local_tools, "local");
// Combine into one
let all_tools = CombinedToolset::new()
.with_toolset(prefixed_web)
.with_toolset(prefixed_local);Re-exports§
pub use abstract_toolset::AbstractToolset;pub use abstract_toolset::BoxedToolset;pub use abstract_toolset::ToolsetInfo;pub use abstract_toolset::ToolsetResult;pub use abstract_toolset::ToolsetTool;pub use approval::checkers as approval_checkers;pub use approval::ApprovalRequiredToolset;pub use combined::CombinedToolset;pub use dynamic::DynamicToolset;pub use external::ExternalToolset;pub use filtered::filters;pub use filtered::FilteredToolset;pub use function::AsyncFnTool;pub use function::FunctionToolset;pub use prefixed::PrefixedToolset;pub use prepared::preparers;pub use prepared::PreparedToolset;pub use renamed::RenamedToolset;pub use wrapper::LoggingWrapper;pub use wrapper::WrapperToolset;
Modules§
- abstract_
toolset - Core toolset trait and related types.
- approval
- Approval-required toolset implementation.
- combined
- Combined toolset for merging multiple toolsets.
- dynamic
- Dynamic toolset implementation.
- external
- External toolset implementation.
- filtered
- Filtered toolset implementation.
- function
- Function-based toolset implementation.
- prefixed
- Prefixed toolset implementation.
- prelude
- Prelude for common imports.
- prepared
- Prepared toolset implementation.
- renamed
- Renamed toolset implementation.
- wrapper
- Wrapper toolset implementation.