7 releases
| 0.8.1 | Apr 2, 2026 |
|---|---|
| 0.8.0 | Apr 2, 2026 |
| 0.7.0 | Jan 28, 2026 |
| 0.7.0-alpha.4 | Jan 27, 2026 |
#77 in #transformer
12,034 downloads per month
Used in 29 crates
(via mistralrs)
18KB
275 lines
Proc macros for ergonomic tool definition in mistral.rs
This crate provides the #[tool] attribute macro for defining tools
that can be used with the mistral.rs agentic loop.
Example
use mistralrs_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>)
mistralrs-macros
Dependencies
~0.5–0.8MB
~18K SLoC