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

Represents a schema for number types, including integers and floating-point numbers.

Link to this section Summary

Functions

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

Check if json is of type

Link to this section Types

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

Link to this section Functions

Link to this function

from_json(json)

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

examples

Examples

is-of-type

Is of Type

iex> GenAI.Tool.Schema.Number.from_json(%{"type" => "number", "description" => "A number value"})
{:ok, %GenAI.Tool.Schema.Number{description: "A number value"}}

not-of-type

Not of Type

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

Check if json is of type

examples

Examples

is-of-type

Is of Type

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

not-of-type

Not of Type

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