Class: OpenApiOpenAIClient::RealtimeSessionCreateResponse

Inherits:
ApiModelBase
  • Object
show all
Defined in:
lib/openapi_openai/models/realtime_session_create_response.rb

Overview

A new Realtime session configuration, with an ephermeral key. Default TTL for keys is one minute.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ RealtimeSessionCreateResponse

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {}) —

    Model attributes in the form of hash



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 137

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `OpenApiOpenAIClient::RealtimeSessionCreateResponse` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `OpenApiOpenAIClient::RealtimeSessionCreateResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'client_secret')
    self.client_secret = attributes[:'client_secret']
  end

  if attributes.key?(:'modalities')
    if (value = attributes[:'modalities']).is_a?(Array)
      self.modalities = value
    end
  end

  if attributes.key?(:'instructions')
    self.instructions = attributes[:'instructions']
  end

  if attributes.key?(:'voice')
    self.voice = attributes[:'voice']
  end

  if attributes.key?(:'input_audio_format')
    self.input_audio_format = attributes[:'input_audio_format']
  end

  if attributes.key?(:'output_audio_format')
    self.output_audio_format = attributes[:'output_audio_format']
  end

  if attributes.key?(:'input_audio_transcription')
    self.input_audio_transcription = attributes[:'input_audio_transcription']
  end

  if attributes.key?(:'turn_detection')
    self.turn_detection = attributes[:'turn_detection']
  end

  if attributes.key?(:'tools')
    if (value = attributes[:'tools']).is_a?(Array)
      self.tools = value
    end
  end

  if attributes.key?(:'tool_choice')
    self.tool_choice = attributes[:'tool_choice']
  end

  if attributes.key?(:'temperature')
    self.temperature = attributes[:'temperature']
  end

  if attributes.key?(:'max_response_output_tokens')
    self.max_response_output_tokens = attributes[:'max_response_output_tokens']
  end
end

Instance Attribute Details

#client_secret ⇒ Object

Returns the value of attribute client_secret.



19
20
21
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 19

def client_secret
  @client_secret
end

#input_audio_format ⇒ Object

The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw.



31
32
33
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 31

def input_audio_format
  @input_audio_format
end

#input_audio_transcription ⇒ Object

Returns the value of attribute input_audio_transcription.



36
37
38
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 36

def input_audio_transcription
  @input_audio_transcription
end

#instructions ⇒ Object

The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior. Note that the server sets default instructions which will be used if this field is not set and are visible in the session.created event at the start of the session.



25
26
27
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 25

def instructions
  @instructions
end

#max_response_output_tokens ⇒ Object

Returns the value of attribute max_response_output_tokens.



49
50
51
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 49

def max_response_output_tokens
  @max_response_output_tokens
end

#modalities ⇒ Object

The set of modalities the model can respond with. To disable audio, set this to ["text"].



22
23
24
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 22

def modalities
  @modalities
end

#output_audio_format ⇒ Object

The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw.



34
35
36
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 34

def output_audio_format
  @output_audio_format
end

#temperature ⇒ Object

Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.



47
48
49
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 47

def temperature
  @temperature
end

#tool_choice ⇒ Object

How the model chooses tools. Options are auto, none, required, or specify a function.



44
45
46
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 44

def tool_choice
  @tool_choice
end

#tools ⇒ Object

Tools (functions) available to the model.



41
42
43
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 41

def tools
  @tools
end

#turn_detection ⇒ Object

Returns the value of attribute turn_detection.



38
39
40
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 38

def turn_detection
  @turn_detection
end

#voice ⇒ Object

The voice the model uses to respond. Voice cannot be changed during the session once the model has responded with audio at least once. Current voice options are alloy, ash, ballad, coral, echo sage, shimmer and verse.



28
29
30
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 28

def voice
  @voice
end

Class Method Details

.acceptable_attribute_map ⇒ Object

Returns attribute mapping this model knows about



92
93
94
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 92

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributes ⇒ Object

Returns all the JSON keys this model knows about



97
98
99
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 97

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.acceptable_openapi_nullable ⇒ Object

Returns the nullable attributes



131
132
133
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 131

def self.acceptable_openapi_nullable
  openapi_nullable
end

.acceptable_openapi_types ⇒ Object

Returns attribute type mapping



126
127
128
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 126

def self.acceptable_openapi_types
  openapi_types
end

.attribute_map ⇒ Object

Attribute mapping from ruby-style variable name to JSON key.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 74

def self.attribute_map
  {
    :'client_secret' => :'client_secret',
    :'modalities' => :'modalities',
    :'instructions' => :'instructions',
    :'voice' => :'voice',
    :'input_audio_format' => :'input_audio_format',
    :'output_audio_format' => :'output_audio_format',
    :'input_audio_transcription' => :'input_audio_transcription',
    :'turn_detection' => :'turn_detection',
    :'tools' => :'tools',
    :'tool_choice' => :'tool_choice',
    :'temperature' => :'temperature',
    :'max_response_output_tokens' => :'max_response_output_tokens'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash) —

    Model attributes in the form of hash

Returns:

  • (Object) —

    Returns the model itself



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 265

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  # include attributes inherited from allOf parents (the nearest declaration wins)
  map = acceptable_attribute_map
  transformed_hash = {}
  acceptable_openapi_types.each_pair do |key, type|
    if attributes.key?(map[key]) && attributes[map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullable ⇒ Object

List of attributes with nullable: true



120
121
122
123
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 120

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_types ⇒ Object

Attribute type mapping.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 102

def self.openapi_types
  {
    :'client_secret' => :'RealtimeSessionCreateResponseClientSecret',
    :'modalities' => :'Array<String>',
    :'instructions' => :'String',
    :'voice' => :'String',
    :'input_audio_format' => :'String',
    :'output_audio_format' => :'String',
    :'input_audio_transcription' => :'RealtimeSessionInputAudioTranscription',
    :'turn_detection' => :'RealtimeSessionCreateResponseTurnDetection',
    :'tools' => :'Array<RealtimeResponseCreateParamsToolsInner>',
    :'tool_choice' => :'String',
    :'temperature' => :'Float',
    :'max_response_output_tokens' => :'RealtimeResponseCreateParamsMaxResponseOutputTokens'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object) —

    to be compared



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 233

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      client_secret == o.client_secret &&
      modalities == o.modalities &&
      instructions == o.instructions &&
      voice == o.voice &&
      input_audio_format == o.input_audio_format &&
      output_audio_format == o.output_audio_format &&
      input_audio_transcription == o.input_audio_transcription &&
      turn_detection == o.turn_detection &&
      tools == o.tools &&
      tool_choice == o.tool_choice &&
      temperature == o.temperature &&
      max_response_output_tokens == o.max_response_output_tokens
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object) —

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


252
253
254
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 252

def eql?(o)
  self == o
end

#hash ⇒ Integer

Calculates hash code according to all attributes.

Returns:

  • (Integer) —

    Hash code



258
259
260
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 258

def hash
  [client_secret, modalities, instructions, voice, input_audio_format, output_audio_format, input_audio_transcription, turn_detection, tools, tool_choice, temperature, max_response_output_tokens].hash
end

#list_invalid_properties ⇒ Object

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



206
207
208
209
210
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 206

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_hash ⇒ Hash

Returns the object in the form of hash

Returns:

  • (Hash) —

    Returns the object in the form of hash



289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 289

def to_hash
  hash = {}
  # include attributes inherited from allOf parents (the nearest declaration wins)
  self.class.acceptable_attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.acceptable_openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid? ⇒ Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean) —

    true if the model is valid



214
215
216
217
218
219
# File 'lib/openapi_openai/models/realtime_session_create_response.rb', line 214

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  voice_validator = EnumAttributeValidator.new('String', ["alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse"])
  return false unless voice_validator.valid?(@voice)
  true
end