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

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

Link to this section Summary

Functions

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

Check if json is of type

Link to this section Types

@type t() :: %GenAI.Tool.Schema.Object{
  additional_properties: boolean() | map() | nil,
  description: String.t() | nil,
  max_properties: integer() | nil,
  min_properties: integer() | nil,
  pattern_properties: map() | nil,
  properties: map() | nil,
  property_names: map() | nil,
  required: [String.t()] | nil,
  type: String.t()
}

Link to this section Functions

Link to this function

from_json(attributes)

@spec from_json(map()) :: t()

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

examples

Examples

is-of-type

Is of Type

iex> GenAI.Tool.Schema.Object.from_json(%{"type" => "object", "description" => "An object value"})
{:ok, %GenAI.Tool.Schema.Object{type: "object", description: "An object value"}}

not-of-type

Not of Type

iex> GenAI.Tool.Schema.Object.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.Object.is_type(%{"type" => "object"})
true

not-of-type

Not of Type

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