A tool backed by a module instead of an anonymous function.
This solves the problem of tools with anonymous functions not being
usable in compile-time Plug config (e.g., plug MyPlug, tools: [...]).
Usage
Define a module implementing ADK.Tool:
defmodule MyTool do
@behaviour ADK.Tool
@impl true
def name, do: "my_tool"
@impl true
def description, do: "Does something useful"
@impl true
def parameters, do: %{type: "object", properties: %{input: %{type: "string"}}}
@impl true
def run(_ctx, args), do: {:ok, "Got: #{args["input"]}"}
endThen wrap it:
tool = ADK.Tool.ModuleTool.new(MyTool)Or use it directly — any module implementing ADK.Tool can be used
as a tool struct via ADK.Tool.ModuleTool.new/1.
Summary
Types
Functions
Create a tool struct from a module implementing ADK.Tool.
@spec run(t(), ADK.ToolContext.t(), map()) :: ADK.Tool.result()
Execute the module tool.