WardrikCore.Capability behaviour (wardrik_core v0.1.0-rc.1)

Copy Markdown

Gives an agent its tools.

defmodule MyApp.Orders do
  @behaviour WardrikCore.Capability

  @impl true
  def tools(_context, orders) do
    [
      WardrikCore.Tool.new!(
        name: "order_status",
        description: "Say where an order is.",
        schema: [order_id: [type: :string, required: true]],
        run: fn %{order_id: id}, _context -> {:ok, Map.get(orders, id, "unknown")} end
      )
    ]
  end
end

Give it to an agent as capabilities: [{MyApp.Orders, opts}]. opts is passed to tools/2, so one module can serve many agents.

Summary

Callbacks

Returns the tools for an agent, given its context and the options it was given.

Callbacks

tools(t, opts)

@callback tools(WardrikCore.Context.t(), opts :: term()) :: [WardrikCore.Tool.t()]

Returns the tools for an agent, given its context and the options it was given.