Skip to main content

Crate cortexai_macros

Crate cortexai_macros 

Source
Expand description

§Procedural Macros for cortex

This crate provides derive macros for easily defining tools and other agent components with minimal boilerplate.

§Tool Derive Macro

use cortexai_macros::Tool;

#[derive(Tool)]
#[tool(name = "calculator", description = "Perform mathematical calculations")]
struct CalculatorTool {
    #[tool(param, required, description = "The mathematical expression to evaluate")]
    expression: String,

    #[tool(param, description = "Number of decimal places for result")]
    precision: Option<u32>,
}

impl CalculatorTool {
    async fn run(&self, expression: String, precision: Option<u32>) -> Result<serde_json::Value, String> {
        // Implementation here
        Ok(serde_json::json!(42.0))
    }
}

Attribute Macros§

tool
Attribute macro for defining tools from async functions.

Derive Macros§

Tool
Derive macro for creating Tool implementations