Packages

Minimal Elixir AI SDK scaffolding for streaming text with tool calls.

Current section

Files

Jump to
ai_sdk_ex lib ai tool.ex
Raw

lib/ai/tool.ex

defmodule AI.Tool do
@moduledoc """
Tool definition used for tool calling.
"""
defstruct [:name, :description, :input_schema, :execute]
@type t :: %__MODULE__{
name: String.t(),
description: String.t(),
input_schema: map(),
execute: (map() -> term()) | (map(), map() -> term())
}
@doc """
Creates a tool struct from a keyword list or map.
"""
def new(opts) when is_list(opts) or is_map(opts) do
struct!(__MODULE__, Enum.into(opts, %{}))
end
end