AshAi.Tools (ash_ai v0.6.1)

Copy Markdown View Source

High-level API for discovering and building tools from Ash domains.

This module provides the main interface for working with AshAi tools. It builds ReqLLM tools/registries and executes tool calls with consistent JSON:API error formatting.

Architecture

The tool functionality is organized into several specialized modules:

Summary

Functions

Builds a ReqLLM.Tool and callback from a tool definition.

Builds tools and a registry from options.

Executes a tool with the given arguments and context.

Returns a list of ReqLLM.Tool structs for the given options.

Returns the JSON Schema parameter schema for a tool definition.

Returns a registry map of tool names to callbacks.

Functions

build(tool, opts \\ [])

Builds a ReqLLM.Tool and callback from a tool definition.

Delegates to AshAi.Tool.Builder.build/2.

Returns {ReqLLM.Tool, callback_fn} tuple.

build_tools_and_registry(opts)

Builds tools and a registry from options.

Returns {[ReqLLM.Tool], %{name => callback}} tuple.

execute(tool, arguments, context)

Executes a tool with the given arguments and context.

Delegates to AshAi.Tool.Execution.run/3.

Returns {:ok, json_result, raw_result} on success or {:error, json_error} on failure.

list(opts)

Returns a list of ReqLLM.Tool structs for the given options.

parameter_schema(tool, opts \\ [])

Returns the JSON Schema parameter schema for a tool definition.

Delegates to AshAi.Tool.Schema.for_tool/1.

registry(opts)

Returns a registry map of tool names to callbacks.