ailoy-node
    Preparing search index...

    Interface ToolDesc

    Describes a tool (or function) that a language model can invoke.

    ToolDesc defines the schema, behavior, and input/output specification of a callable external function, allowing an LLM to understand how to use it.

    The primary role of this struct is to describe to the LLM what a tool does, how it can be invoked, and what input (parameters) and output (returns) schemas it expects.

    The format follows the same schema conventions used by Hugging Face’s transformers library, as well as APIs such as OpenAI and Anthropic. The parameters and returns fields are typically defined using JSON Schema.

    We provide a builder [ToolDescBuilder] helper for convenient and fluent construction. Please refer to [ToolDescBuilder].

    Example

    use crate::value::{ToolDescBuilder, to_value};

    let desc = ToolDescBuilder::new("temperature")
    .description("Get the current temperature for a given city")
    .parameters(to_value!({
    "type": "object",
    "properties": {
    "location": {
    "type": "string",
    "description": "The city name"
    },
    "unit": {
    "type": "string",
    "description": "Temperature unit (default: Celsius)",
    "enum": ["Celsius", "Fahrenheit"]
    }
    },
    "required": ["location"]
    }))
    .returns(to_value!({
    "type": "number"
    }))
    .build();

    assert_eq!(desc.name, "temperature");
    interface ToolDesc {
        description?: string;
        name: string;
        parameters: any;
        returns?: any;
    }
    Index

    Properties

    description?: string

    A natural-language description of what the tool does.

    name: string

    The unique name of the tool or function.

    parameters: any

    A [Value] describing the JSON Schema of the expected parameters. Typically an object schema such as { "type": "object", "properties": ... }.

    returns?: any

    An optional [Value] that defines the return value schema. If omitted, the tool is assumed to return free-form text or JSON.