LlmEx.Tools.Declarative (LlmEx v0.1.0)

View Source

Provides a declarative API for defining tool schemas.

This module implements macros similar to Phoenix.Component's attr macro, allowing tool developers to define their tools in a more declarative style.

Summary

Functions

Declares a parameter for a tool.

Sets the description of the tool.

Sets the name of the tool.

Functions

param(name, type, opts \\ [])

(macro)

Declares a parameter for a tool.

Arguments

  • name - an atom or string defining the name of the parameter
  • type - an atom defining the type of the parameter (":string", ":integer", etc.)
  • opts - a keyword list of options. Defaults to []

Options

  • :required - marks a parameter as required. Defaults to false
  • :description - documentation for the parameter
  • :enum - a list of allowed values for the parameter
  • :default - the default value for the parameter if not provided

Examples

param :action, :string, required: true, enum: ["increment", "decrement", "reset"],
                       description: "The action to perform"

tool_description(description)

(macro)

Sets the description of the tool.

Examples

tool_description "A stateful counter that increments, decrements, or resets"

tool_name(name)

(macro)

Sets the name of the tool.

Examples

tool_name "counter"