GenAI.Tool.Schema.Enum (GenAI Core v0.3.2)

Copy Markdown

Represents a schema for enum types, converting JSON schema attributes to Elixir struct fields.

Summary

Functions

Convert Json map to a GenAI.Tool.Schema.Enum struct, handling naming conventions.

Check if json is of type

Types

t()

@type t() :: %GenAI.Tool.Schema.Enum{
  description: String.t() | nil,
  enum: [String.t()],
  type: String.t()
}

Functions

from_json(json)

Convert Json map to a GenAI.Tool.Schema.Enum struct, handling naming conventions.

Examples

Is of Type

iex> GenAI.Tool.Schema.Enum.from_json(%{"type" => "string", "enum" => ["value1", "value2"], "description" => "An enum value"})
{:ok, %GenAI.Tool.Schema.Enum{type: "string", enum: ["value1", "value2"], description: "An enum value"}}

Not of Type

iex> GenAI.Tool.Schema.Enum.from_json(%{"type" => "number"})
{:error, :unrecognized_type}

is_type(arg1)

Check if json is of type

Examples

Is of Type

iex> GenAI.Tool.Schema.Enum.is_type(%{"type" => "string", "enum" => ["value1", "value2"]})
true

Not of Type

iex> GenAI.Tool.Schema.Enum.is_type(%{"type" => "string"})
false