AshAi.Tool.Builder (ash_ai v0.6.1)

Copy Markdown View Source

Builds ReqLLM.Tool structs and callbacks from AshAi.Tool DSL entities.

This module is responsible for converting AshAi tool definitions into the format expected by ReqLLM, including generating the parameter schema and creating the callback function that executes the tool.

Summary

Functions

Builds a ReqLLM.Tool struct and callback function from an AshAi.Tool definition.

Functions

build(tool_def, opts \\ [])

Builds a ReqLLM.Tool struct and callback function from an AshAi.Tool definition.

Returns a tuple of {ReqLLM.Tool, callback_fn} where:

  • ReqLLM.Tool contains the tool schema for the LLM
  • callback_fn is a function/2 that takes (arguments, context) and executes the Ash action

Example

{tool, callback} = AshAi.Tool.Builder.build(tool_def)
result = callback.(%{"input" => %{"name" => "foo"}}, %{actor: current_user})