GenAI.Tool.Registry (GenAI Core v0.3.4)

Copy Markdown

Immutable registry that gives heterogeneous tool sources one deterministic model-facing namespace.

Names are exposed as source__tool by default. Invalid characters become _; collisions fail with {:error, {:tool_name_collision, name}} unless the caller explicitly selects collision: :keep or collision: :replace.

Summary

Functions

Executes a normalized call through its owning source.

Returns the registered model-facing names in deterministic order.

Registers and snapshots the current tools from a source.

Returns model-facing GenAI.Tool values in deterministic name order.

Types

t()

@type t() :: %GenAI.Tool.Registry{
  entries: %{required(String.t()) => GenAI.Tool.Registry.Entry.t()},
  options: keyword(),
  sources: map()
}

Functions

execute(registry, call, context \\ nil, options \\ [])

@spec execute(t(), term(), term(), keyword()) ::
  {:ok, GenAI.Tool.Result.t()} | {:error, GenAI.Tool.Result.t() | term()}

Executes a normalized call through its owning source.

names(registry)

Returns the registered model-facing names in deterministic order.

new(options \\ [])

@spec new(keyword()) :: t()

register(registry, source_id, module, source, context \\ nil, options \\ [])

@spec register(t(), term(), module(), term(), term(), keyword()) ::
  {:ok, t()} | {:error, term()}

Registers and snapshots the current tools from a source.

tools(registry)

@spec tools(t()) :: [GenAI.Tool.t()]

Returns model-facing GenAI.Tool values in deterministic name order.