Class: OpenAI::Models::ResponseFormatJSONSchema::JSONSchema

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/openai/models/response_format_json_schema.rb,
sig/openai/models/response_format_json_schema.rbs

Overview

See Also:

  • OpenAI::Models::ResponseFormatJSONSchema#json_schema

Instance Attribute Summary collapse

Attributes inherited from Internal::Type::BaseModel

#last_response

Instance Method Summary collapse

Methods inherited from Internal::Type::BaseModel

==, #==, #[], #_request_id, #_set_last_response, coerce, #deconstruct_keys, #deep_to_h, dump, #encode_with, fields, hash, #hash, inherited, #inspect, inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml

Methods included from Internal::Type::Converter

#coerce, coerce, coerce_cached, coerce_with_error, #dump, dump, #inspect, inspect, meta_info, new_coerce_state, resolve_type, type_info

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Constructor Details

#initialize(name:, description: nil, schema: nil, strict: nil) ⇒ JSONSchema

Returns a new instance of JSONSchema.

Parameters:

  • name —

    The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

  • description (defaults to: nil) —

    A description of what the response format is for, used by the model to determine how to respond in the format.

  • schema (defaults to: nil) —

    The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.

  • strict (defaults to: nil) —

    Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true. To learn more, read the Structured Outputs guide.

  • name: (String)
  • description: (String) (defaults to: nil)
  • schema: (::Hash[Symbol, top]) (defaults to: nil)
  • strict: (Boolean, nil) (defaults to: nil)


# File 'lib/openai/models/response_format_json_schema.rb', line 70

Instance Attribute Details

#description ⇒ String?

A description of what the response format is for, used by the model to determine how to respond in the format.

Returns:

  • (String, nil)


43
# File 'lib/openai/models/response_format_json_schema.rb', line 43

optional :description, String

#name ⇒ String

The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.

Returns:

  • (String)


36
# File 'lib/openai/models/response_format_json_schema.rb', line 36

required :name, String

#schema ⇒ ::Hash[Symbol, top]?

The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas here.

Returns:

  • (::Hash[Symbol, top], nil)


50
51
52
53
54
55
56
57
58
# File 'lib/openai/models/response_format_json_schema.rb', line 50

optional(
  :schema,
  union: -> {
    OpenAI::UnionOf[
      OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown],
      OpenAI::StructuredOutput::JsonSchemaConverter
    ]
  }
)

#strict ⇒ Boolean?

Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true. To learn more, read the Structured Outputs guide.

Returns:



68
# File 'lib/openai/models/response_format_json_schema.rb', line 68

optional :strict, OpenAI::Internal::Type::Boolean, nil?: true

Instance Method Details

#to_hash ⇒ { name: String, ?description: String, ?schema: ::Hash[Symbol, top], ?strict: bool? }

Returns:

  • ({ name: String, ?description: String, ?schema: ::Hash[Symbol, top], ?strict: bool? })


88
89
90
91
92
93
# File 'sig/openai/models/response_format_json_schema.rbs', line 88

def to_hash: -> {
  name: String,
  ?description: String,
  ?schema: ::Hash[Symbol, top],
  ?strict: bool?
}