Provider-neutral tool definition.
A tool is a pure data structure: name, description, and a JSON Schema
describing the parameters the tool accepts. The callback (how to actually
execute the tool) is not part of this struct — it is resolved at
runtime by the host application via a LlmToolkit.ToolResolver.
This separation ensures tool definitions are serializable (YAML config, MCP exposure, storage) while callbacks remain a runtime concern.
Fields
name- Unique tool identifier (required)description- Human-readable description for the LLM (required)parameters- JSON Schema map describing accepted arguments (required)metadata- Optional map for tags, version, source, etc.
Examples
iex> LlmToolkit.Tool.new(%{
...> name: "search",
...> description: "Search the knowledge base",
...> parameters: %{
...> "type" => "object",
...> "properties" => %{"query" => %{"type" => "string"}}
...> }
...> })
{:ok,
%LlmToolkit.Tool{
name: "search",
description: "Search the knowledge base",
parameters: %{
"type" => "object",
"properties" => %{"query" => %{"type" => "string"}}
},
metadata: %{}
}}
Summary
Functions
Creates a Tool from a plain map, typically loaded from YAML.
Creates a new Tool from a map of attributes.
Types
Functions
Creates a Tool from a plain map, typically loaded from YAML.
Accepts string keys and converts them.
Creates a new Tool from a map of attributes.
Returns {:ok, tool} on success or {:error, reason} when required
fields are missing or invalid.