Expand description
Procedural macro for deriving BaseTool implementations from functions.
§Example
ⓘ
use lc_tools::{tool, BaseTool, Tool, ToolError};
#[tool(description = "Useful for arithmetic calculations")]
fn calculator(
#[param(desc = "The mathematical expression to evaluate")]
expression: String,
) -> Result<f64, ToolError> {
expression
.parse::<f64>()
.map_err(|e| ToolError::ExecutionFailed(e.to_string()))
}This expands to:
CalculatorToolstructCalculatorInputstruct withDeserialize+JsonSchemaimpl BaseTool for CalculatorToolimpl Tool for CalculatorTool- The original
calculatorfunction is preserved
Attribute Macros§
- tool
- The
#[tool]procedural macro.