CouncilEx.Tool behaviour (CouncilEx v0.1.0)

Copy Markdown View Source

Behaviour for tools an LLM member can call mid-completion.

Tools self-describe via name/0, description/0, and parameters_schema/0 (an Ecto embedded schema reused by CouncilEx.Schema.JSONSchema). The provider-side dispatcher calls execute/1 with a struct cast from the LLM's tool-call arguments.

Example

defmodule MyTools.Calculator do
  use Ecto.Schema

  @primary_key false
  embedded_schema do
    field :a, :float
    field :b, :float
    field :op, :string
  end

  @behaviour CouncilEx.Tool
  def name, do: "calculator"
  def description, do: "Perform arithmetic on two numbers."
  def parameters_schema, do: __MODULE__

  def execute(%{op: "add", a: a, b: b}), do: {:ok, a + b}
end

Summary

Callbacks

description()

@callback description() :: String.t()

execute(args)

@callback execute(args :: struct()) :: {:ok, term()} | {:error, term()}

name()

@callback name() :: String.t()

parameters_schema()

@callback parameters_schema() :: module()