Class: OpenApiOpenAIClient::RunObject

Inherits:
ApiModelBase show all
Defined in:
lib/openapi_openai/models/run_object.rb

Overview

Represents an execution run on a [thread](/docs/api-reference/threads).

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 = {}) ⇒ RunObject

Initializes the object

Parameters:

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

    Model attributes in the form of hash



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/openapi_openai/models/run_object.rb', line 213

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `OpenApiOpenAIClient::RunObject` 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::RunObject`. 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?(:'id')
    self.id = attributes[:'id']
  else
    self.id = nil
  end

  if attributes.key?(:'object')
    self.object = attributes[:'object']
  else
    self.object = nil
  end

  if attributes.key?(:'created_at')
    self.created_at = attributes[:'created_at']
  else
    self.created_at = nil
  end

  if attributes.key?(:'thread_id')
    self.thread_id = attributes[:'thread_id']
  else
    self.thread_id = nil
  end

  if attributes.key?(:'assistant_id')
    self.assistant_id = attributes[:'assistant_id']
  else
    self.assistant_id = nil
  end

  if attributes.key?(:'status')
    self.status = attributes[:'status']
  else
    self.status = nil
  end

  if attributes.key?(:'required_action')
    self.required_action = attributes[:'required_action']
  else
    self.required_action = nil
  end

  if attributes.key?(:'last_error')
    self.last_error = attributes[:'last_error']
  else
    self.last_error = nil
  end

  if attributes.key?(:'expires_at')
    self.expires_at = attributes[:'expires_at']
  else
    self.expires_at = nil
  end

  if attributes.key?(:'started_at')
    self.started_at = attributes[:'started_at']
  else
    self.started_at = nil
  end

  if attributes.key?(:'cancelled_at')
    self.cancelled_at = attributes[:'cancelled_at']
  else
    self.cancelled_at = nil
  end

  if attributes.key?(:'failed_at')
    self.failed_at = attributes[:'failed_at']
  else
    self.failed_at = nil
  end

  if attributes.key?(:'completed_at')
    self.completed_at = attributes[:'completed_at']
  else
    self.completed_at = nil
  end

  if attributes.key?(:'incomplete_details')
    self.incomplete_details = attributes[:'incomplete_details']
  else
    self.incomplete_details = nil
  end

  if attributes.key?(:'model')
    self.model = attributes[:'model']
  else
    self.model = nil
  end

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

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

  if attributes.key?(:'metadata')
    self. = attributes[:'metadata']
  else
    self. = nil
  end

  if attributes.key?(:'usage')
    self.usage = attributes[:'usage']
  else
    self.usage = nil
  end

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

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

  if attributes.key?(:'max_prompt_tokens')
    self.max_prompt_tokens = attributes[:'max_prompt_tokens']
  else
    self.max_prompt_tokens = nil
  end

  if attributes.key?(:'max_completion_tokens')
    self.max_completion_tokens = attributes[:'max_completion_tokens']
  else
    self.max_completion_tokens = nil
  end

  if attributes.key?(:'truncation_strategy')
    self.truncation_strategy = attributes[:'truncation_strategy']
  else
    self.truncation_strategy = nil
  end

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

  if attributes.key?(:'parallel_tool_calls')
    self.parallel_tool_calls = attributes[:'parallel_tool_calls']
  else
    self.parallel_tool_calls = true
  end

  if attributes.key?(:'response_format')
    self.response_format = attributes[:'response_format']
  else
    self.response_format = nil
  end
end

Instance Attribute Details

#assistant_idObject

The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run.



32
33
34
# File 'lib/openapi_openai/models/run_object.rb', line 32

def assistant_id
  @assistant_id
end

#cancelled_atObject

The Unix timestamp (in seconds) for when the run was cancelled.



48
49
50
# File 'lib/openapi_openai/models/run_object.rb', line 48

def cancelled_at
  @cancelled_at
end

#completed_atObject

The Unix timestamp (in seconds) for when the run was completed.



54
55
56
# File 'lib/openapi_openai/models/run_object.rb', line 54

def completed_at
  @completed_at
end

#created_atObject

The Unix timestamp (in seconds) for when the run was created.



26
27
28
# File 'lib/openapi_openai/models/run_object.rb', line 26

def created_at
  @created_at
end

#expires_atObject

The Unix timestamp (in seconds) for when the run will expire.



42
43
44
# File 'lib/openapi_openai/models/run_object.rb', line 42

def expires_at
  @expires_at
end

#failed_atObject

The Unix timestamp (in seconds) for when the run failed.



51
52
53
# File 'lib/openapi_openai/models/run_object.rb', line 51

def failed_at
  @failed_at
end

#idObject

The identifier, which can be referenced in API endpoints.



20
21
22
# File 'lib/openapi_openai/models/run_object.rb', line 20

def id
  @id
end

#incomplete_detailsObject

Returns the value of attribute incomplete_details.



56
57
58
# File 'lib/openapi_openai/models/run_object.rb', line 56

def incomplete_details
  @incomplete_details
end

#instructionsObject

The instructions that the [assistant](/docs/api-reference/assistants) used for this run.



62
63
64
# File 'lib/openapi_openai/models/run_object.rb', line 62

def instructions
  @instructions
end

#last_errorObject

Returns the value of attribute last_error.



39
40
41
# File 'lib/openapi_openai/models/run_object.rb', line 39

def last_error
  @last_error
end

#max_completion_tokensObject

The maximum number of completion tokens specified to have been used over the course of the run.



82
83
84
# File 'lib/openapi_openai/models/run_object.rb', line 82

def max_completion_tokens
  @max_completion_tokens
end

#max_prompt_tokensObject

The maximum number of prompt tokens specified to have been used over the course of the run.



79
80
81
# File 'lib/openapi_openai/models/run_object.rb', line 79

def max_prompt_tokens
  @max_prompt_tokens
end

#metadataObject

Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.



68
69
70
# File 'lib/openapi_openai/models/run_object.rb', line 68

def 
  @metadata
end

#modelObject

The model that the [assistant](/docs/api-reference/assistants) used for this run.



59
60
61
# File 'lib/openapi_openai/models/run_object.rb', line 59

def model
  @model
end

#objectObject

The object type, which is always thread.run.



23
24
25
# File 'lib/openapi_openai/models/run_object.rb', line 23

def object
  @object
end

#parallel_tool_callsObject

Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.



89
90
91
# File 'lib/openapi_openai/models/run_object.rb', line 89

def parallel_tool_calls
  @parallel_tool_calls
end

#required_actionObject

Returns the value of attribute required_action.



37
38
39
# File 'lib/openapi_openai/models/run_object.rb', line 37

def required_action
  @required_action
end

#response_formatObject

Returns the value of attribute response_format.



91
92
93
# File 'lib/openapi_openai/models/run_object.rb', line 91

def response_format
  @response_format
end

#started_atObject

The Unix timestamp (in seconds) for when the run was started.



45
46
47
# File 'lib/openapi_openai/models/run_object.rb', line 45

def started_at
  @started_at
end

#statusObject

The status of the run, which can be either queued, in_progress, requires_action, cancelling, cancelled, failed, completed, incomplete, or expired.



35
36
37
# File 'lib/openapi_openai/models/run_object.rb', line 35

def status
  @status
end

#temperatureObject

The sampling temperature used for this run. If not set, defaults to 1.



73
74
75
# File 'lib/openapi_openai/models/run_object.rb', line 73

def temperature
  @temperature
end

#thread_idObject

The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run.



29
30
31
# File 'lib/openapi_openai/models/run_object.rb', line 29

def thread_id
  @thread_id
end

#tool_choiceObject

Returns the value of attribute tool_choice.



86
87
88
# File 'lib/openapi_openai/models/run_object.rb', line 86

def tool_choice
  @tool_choice
end

#toolsObject

The list of tools that the [assistant](/docs/api-reference/assistants) used for this run.



65
66
67
# File 'lib/openapi_openai/models/run_object.rb', line 65

def tools
  @tools
end

#top_pObject

The nucleus sampling value used for this run. If not set, defaults to 1.



76
77
78
# File 'lib/openapi_openai/models/run_object.rb', line 76

def top_p
  @top_p
end

#truncation_strategyObject

Returns the value of attribute truncation_strategy.



84
85
86
# File 'lib/openapi_openai/models/run_object.rb', line 84

def truncation_strategy
  @truncation_strategy
end

#usageObject

Returns the value of attribute usage.



70
71
72
# File 'lib/openapi_openai/models/run_object.rb', line 70

def usage
  @usage
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



149
150
151
# File 'lib/openapi_openai/models/run_object.rb', line 149

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



154
155
156
# File 'lib/openapi_openai/models/run_object.rb', line 154

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/openapi_openai/models/run_object.rb', line 116

def self.attribute_map
  {
    :'id' => :'id',
    :'object' => :'object',
    :'created_at' => :'created_at',
    :'thread_id' => :'thread_id',
    :'assistant_id' => :'assistant_id',
    :'status' => :'status',
    :'required_action' => :'required_action',
    :'last_error' => :'last_error',
    :'expires_at' => :'expires_at',
    :'started_at' => :'started_at',
    :'cancelled_at' => :'cancelled_at',
    :'failed_at' => :'failed_at',
    :'completed_at' => :'completed_at',
    :'incomplete_details' => :'incomplete_details',
    :'model' => :'model',
    :'instructions' => :'instructions',
    :'tools' => :'tools',
    :'metadata' => :'metadata',
    :'usage' => :'usage',
    :'temperature' => :'temperature',
    :'top_p' => :'top_p',
    :'max_prompt_tokens' => :'max_prompt_tokens',
    :'max_completion_tokens' => :'max_completion_tokens',
    :'truncation_strategy' => :'truncation_strategy',
    :'tool_choice' => :'tool_choice',
    :'parallel_tool_calls' => :'parallel_tool_calls',
    :'response_format' => :'response_format'
  }
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



690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
# File 'lib/openapi_openai/models/run_object.rb', line 690

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_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[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/openapi_openai/models/run_object.rb', line 192

def self.openapi_nullable
  Set.new([
    :'required_action',
    :'last_error',
    :'expires_at',
    :'started_at',
    :'cancelled_at',
    :'failed_at',
    :'completed_at',
    :'incomplete_details',
    :'metadata',
    :'usage',
    :'temperature',
    :'top_p',
    :'max_prompt_tokens',
    :'max_completion_tokens',
  ])
end

.openapi_typesObject

Attribute type mapping.



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
# File 'lib/openapi_openai/models/run_object.rb', line 159

def self.openapi_types
  {
    :'id' => :'String',
    :'object' => :'String',
    :'created_at' => :'Integer',
    :'thread_id' => :'String',
    :'assistant_id' => :'String',
    :'status' => :'String',
    :'required_action' => :'RunObjectRequiredAction',
    :'last_error' => :'RunObjectLastError',
    :'expires_at' => :'Integer',
    :'started_at' => :'Integer',
    :'cancelled_at' => :'Integer',
    :'failed_at' => :'Integer',
    :'completed_at' => :'Integer',
    :'incomplete_details' => :'RunObjectIncompleteDetails',
    :'model' => :'String',
    :'instructions' => :'String',
    :'tools' => :'Array<AssistantObjectToolsInner>',
    :'metadata' => :'Object',
    :'usage' => :'RunCompletionUsage',
    :'temperature' => :'Float',
    :'top_p' => :'Float',
    :'max_prompt_tokens' => :'Integer',
    :'max_completion_tokens' => :'Integer',
    :'truncation_strategy' => :'TruncationObject',
    :'tool_choice' => :'AssistantsApiToolChoiceOption',
    :'parallel_tool_calls' => :'Boolean',
    :'response_format' => :'AssistantsApiResponseFormatOption'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
# File 'lib/openapi_openai/models/run_object.rb', line 643

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      object == o.object &&
      created_at == o.created_at &&
      thread_id == o.thread_id &&
      assistant_id == o.assistant_id &&
      status == o.status &&
      required_action == o.required_action &&
      last_error == o.last_error &&
      expires_at == o.expires_at &&
      started_at == o.started_at &&
      cancelled_at == o.cancelled_at &&
      failed_at == o.failed_at &&
      completed_at == o.completed_at &&
      incomplete_details == o.incomplete_details &&
      model == o.model &&
      instructions == o.instructions &&
      tools == o.tools &&
       == o. &&
      usage == o.usage &&
      temperature == o.temperature &&
      top_p == o.top_p &&
      max_prompt_tokens == o.max_prompt_tokens &&
      max_completion_tokens == o.max_completion_tokens &&
      truncation_strategy == o.truncation_strategy &&
      tool_choice == o.tool_choice &&
      parallel_tool_calls == o.parallel_tool_calls &&
      response_format == o.response_format
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


677
678
679
# File 'lib/openapi_openai/models/run_object.rb', line 677

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



683
684
685
# File 'lib/openapi_openai/models/run_object.rb', line 683

def hash
  [id, object, created_at, thread_id, assistant_id, status, required_action, last_error, expires_at, started_at, cancelled_at, failed_at, completed_at, incomplete_details, model, instructions, tools, , usage, temperature, top_p, max_prompt_tokens, max_completion_tokens, truncation_strategy, tool_choice, parallel_tool_calls, response_format].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/openapi_openai/models/run_object.rb', line 390

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @id.nil?
    invalid_properties.push('invalid value for "id", id cannot be nil.')
  end

  if @object.nil?
    invalid_properties.push('invalid value for "object", object cannot be nil.')
  end

  if @created_at.nil?
    invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
  end

  if @thread_id.nil?
    invalid_properties.push('invalid value for "thread_id", thread_id cannot be nil.')
  end

  if @assistant_id.nil?
    invalid_properties.push('invalid value for "assistant_id", assistant_id cannot be nil.')
  end

  if @status.nil?
    invalid_properties.push('invalid value for "status", status cannot be nil.')
  end

  if @model.nil?
    invalid_properties.push('invalid value for "model", model cannot be nil.')
  end

  if @instructions.nil?
    invalid_properties.push('invalid value for "instructions", instructions cannot be nil.')
  end

  if @tools.nil?
    invalid_properties.push('invalid value for "tools", tools cannot be nil.')
  end

  if @tools.length > 20
    invalid_properties.push('invalid value for "tools", number of items must be less than or equal to 20.')
  end

  if @max_prompt_tokens < 256
    invalid_properties.push('invalid value for "max_prompt_tokens", must be greater than or equal to 256.')
  end

  if @max_completion_tokens < 256
    invalid_properties.push('invalid value for "max_completion_tokens", must be greater than or equal to 256.')
  end

  if @truncation_strategy.nil?
    invalid_properties.push('invalid value for "truncation_strategy", truncation_strategy cannot be nil.')
  end

  if @tool_choice.nil?
    invalid_properties.push('invalid value for "tool_choice", tool_choice cannot be nil.')
  end

  if @parallel_tool_calls.nil?
    invalid_properties.push('invalid value for "parallel_tool_calls", parallel_tool_calls cannot be nil.')
  end

  if @response_format.nil?
    invalid_properties.push('invalid value for "response_format", response_format cannot be nil.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



712
713
714
715
716
717
718
719
720
721
722
723
724
# File 'lib/openapi_openai/models/run_object.rb', line 712

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.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



462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
# File 'lib/openapi_openai/models/run_object.rb', line 462

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @object.nil?
  object_validator = EnumAttributeValidator.new('String', ["thread.run"])
  return false unless object_validator.valid?(@object)
  return false if @created_at.nil?
  return false if @thread_id.nil?
  return false if @assistant_id.nil?
  return false if @status.nil?
  status_validator = EnumAttributeValidator.new('String', ["queued", "in_progress", "requires_action", "cancelling", "cancelled", "failed", "completed", "incomplete", "expired"])
  return false unless status_validator.valid?(@status)
  return false if @model.nil?
  return false if @instructions.nil?
  return false if @tools.nil?
  return false if @tools.length > 20
  return false if @max_prompt_tokens < 256
  return false if @max_completion_tokens < 256
  return false if @truncation_strategy.nil?
  return false if @tool_choice.nil?
  return false if @parallel_tool_calls.nil?
  return false if @response_format.nil?
  true
end