tiny-loop 0.5.1

Minimal AI agent framework
Documentation
use crate::types::{Parameters, ToolDefinition, ToolFunction};
use schemars::JsonSchema;
use serde::Deserialize;

/// Provides tool name, description, and definitions for tools generated by the [`#[tool]`](crate::tool::tool) macro.
pub trait ToolArgs: JsonSchema + for<'a> Deserialize<'a> {
    const TOOL_NAME: &'static str;
    const TOOL_DESCRIPTION: &'static str;

    /// Generates the tool definition with name, description, and parameter schema.
    fn definition() -> ToolDefinition {
        ToolDefinition {
            tool_type: "function".to_string(),
            function: ToolFunction {
                name: Self::TOOL_NAME.to_string(),
                description: Self::TOOL_DESCRIPTION.to_string(),
                parameters: Parameters::from_type::<Self>(),
            },
        }
    }
}