Skip to main content

Crate hanzo_macros

Crate hanzo_macros 

Source
Expand description

Proc macros for ergonomic tool definition in hanzo

This crate provides the #[tool] attribute macro for defining tools that can be used with the hanzo agentic loop.

§Example

use hanzo_macros::tool;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, JsonSchema)]
struct WeatherInfo {
    temperature: f32,
    conditions: String,
}

#[tool(description = "Get the current weather for a location")]
fn get_weather(
    #[description = "The city name"]
    city: String,
) -> anyhow::Result<WeatherInfo> {
    Ok(WeatherInfo {
        temperature: 22.5,
        conditions: "Sunny".to_string(),
    })
}

// This generates:
// - get_weather_tool() -> Tool
// - get_weather_callback() -> Arc<ToolCallback>
// - get_weather_tool_with_callback() -> (Tool, Arc<ToolCallback>)

Attribute Macros§

tool
The #[tool] attribute macro for defining tools.