ToolCall

CI codecov Elixir License: MIT

Derive LLM tool-call schemas from Elixir @spec and @doc, then dispatch the call back to the function.

No DSL, no second schema, no runtime reflection.

defmodule MyApp.Tools.Weather do
  use ToolCall

  @doc """
  Get the forecast for a city.

  ## Parameters
    * `city` - city name
    * `days` - how many days ahead
  """
  @spec get_weather(city :: String.t(), days :: pos_integer() | nil) ::
          {:ok, map()} | {:error, String.t()}
  def get_weather(city, days \\ 3) do
    {:ok, %{city: city, days: days, temp: 21.5}}
  end
end
ToolCall.emit(MyApp.Tools.Weather, :openai)

ToolCall.run(MyApp.Tools.Weather, :get_weather, %{"city" => "Oslo"})
#=> {:ok, %{city: "Oslo", days: 3, temp: 21.5}}

Installation

def deps do
  [tool_call: "~> 0.1"]
end

Requires Elixir ~> 1.18 and Erlang/OTP 27.1+. The OTP floor is enforced at compile time; there are no runtime dependencies.

What you get

Documentation

The full documentation is generated by mix docs:

Development

mix deps.get
mix ci
mix coveralls.html

mix ci runs compile/format checks, tests, spec_lint, Credo, Dialyzer, ExDNA and Reach. mix coveralls.html writes the HTML coverage report to cover/ and fails below 100%. CI uploads the report to Codecov when CODECOV_TOKEN is configured.

License

MIT