Skip to main content

Crate serdes_ai_macros

Crate serdes_ai_macros 

Source
Expand description

§serdes-ai-macros

Procedural macros for serdes-ai.

This crate provides derive macros and attribute macros to reduce boilerplate when defining tools, agents, and output schemas.

§Tool Macro

#[derive(Tool)]
#[tool(name = "get_weather", description = "Get current weather")]
struct GetWeather {
    city: String,
    units: Option<String>,
}

§Output Schema Macro

#[derive(OutputSchema)]
#[output(description = "Weather response")]
struct WeatherResponse {
    /// Temperature in requested units
    temperature: f64,
    /// Weather description
    description: String,
}

§Agent Macro

#[derive(Agent)]
#[agent(model = "openai:gpt-4", system_prompt = "You are helpful.")]
struct MyAgent;

Attribute Macros§

agent
Attribute macro for defining agents.
tool
Attribute macro for creating tools from functions.

Derive Macros§

Agent
Derive macro for implementing agent configuration.
OutputSchema
Derive macro for implementing the OutputSchema trait.
Tool
Derive macro for implementing the Tool trait.