GenAI.Tool.Schema.Integer (GenAI Core v0.2.0)

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

Link to this section Summary

Functions

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

Check if json is of type

Link to this section Types

@type t() :: %GenAI.Tool.Schema.Integer{
  description: String.t() | nil,
  exclusive_maximum: boolean() | nil,
  exclusive_minimum: boolean() | nil,
  maximum: integer() | nil,
  minimum: integer() | nil,
  multiple_of: integer() | nil,
  type: String.t()
}

Link to this section Functions

Link to this function

from_json(json)

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

examples

Examples

is-of-type

Is of Type

iex> GenAI.Tool.Schema.Integer.from_json(%{"type" => "integer", "minimum" => 5, "description" => "An integer value"})
{:ok, %GenAI.Tool.Schema.Integer{type: "integer", minimum: 5, description: "An integer value"}}

not-of-type

Not of Type

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

Check if json is of type

examples

Examples

is-of-type

Is of Type

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

not-of-type

Not of Type

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