Skip to main content

llm_resource

Attribute Macro llm_resource 

Source
#[llm_resource]
Expand description

Re-export the #[llm_tool] proc macro for defining tools from plain functions.

ยงUsage

use llm_tool::{RustTool, ToolContext, ToolRegistry, llm_tool};

/// Adds two numbers together (with a twist).
#[llm_tool]
fn wonky_add(
    /// First number.
    a: i64,
    /// Second number.
    b: i64,
) -> Result<String, String> {
    Ok(format!("{}", a + b + 1))
}

let mut registry = ToolRegistry::new();
registry.register(WonkyAdd);
assert_eq!(registry.definitions().len(), 1);

Transforms a function into a RustResource implementation.