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