Class: OpenApiOpenAIClient::UsageCompletionsResult
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- OpenApiOpenAIClient::UsageCompletionsResult
- Defined in:
- lib/openapi_openai/models/usage_completions_result.rb
Overview
The aggregated completions usage details of the specific time bucket.
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#api_key_id ⇒ Object
When
group_by=api_key_id, this field provides the API key ID of the grouped usage result. -
#batch ⇒ Object
When
group_by=batch, this field tells whether the grouped usage result is batch or not. -
#input_audio_tokens ⇒ Object
The aggregated number of audio input tokens used, including cached tokens.
-
#input_cached_tokens ⇒ Object
The aggregated number of text input tokens that has been cached from previous requests.
-
#input_tokens ⇒ Object
The aggregated number of text input tokens used, including cached tokens.
-
#model ⇒ Object
When
group_by=model, this field provides the model name of the grouped usage result. -
#num_model_requests ⇒ Object
The count of requests made to the model.
-
#object ⇒ Object
Returns the value of attribute object.
-
#output_audio_tokens ⇒ Object
The aggregated number of audio output tokens used.
-
#output_tokens ⇒ Object
The aggregated number of text output tokens used.
-
#project_id ⇒ Object
When
group_by=project_id, this field provides the project ID of the grouped usage result. -
#user_id ⇒ Object
When
group_by=user_id, this field provides the user ID of the grouped usage result.
Class Method Summary collapse
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ UsageCompletionsResult
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from ApiModelBase
_deserialize, #_to_hash, #to_body, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ UsageCompletionsResult
Initializes the object
135 136 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 203 204 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 135 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `OpenApiOpenAIClient::UsageCompletionsResult` 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::UsageCompletionsResult`. 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?(:'object') self.object = attributes[:'object'] else self.object = nil end if attributes.key?(:'input_tokens') self.input_tokens = attributes[:'input_tokens'] else self.input_tokens = nil end if attributes.key?(:'input_cached_tokens') self.input_cached_tokens = attributes[:'input_cached_tokens'] end if attributes.key?(:'output_tokens') self.output_tokens = attributes[:'output_tokens'] else self.output_tokens = nil end if attributes.key?(:'input_audio_tokens') self.input_audio_tokens = attributes[:'input_audio_tokens'] end if attributes.key?(:'output_audio_tokens') self.output_audio_tokens = attributes[:'output_audio_tokens'] end if attributes.key?(:'num_model_requests') self.num_model_requests = attributes[:'num_model_requests'] else self.num_model_requests = nil end if attributes.key?(:'project_id') self.project_id = attributes[:'project_id'] end if attributes.key?(:'user_id') self.user_id = attributes[:'user_id'] end if attributes.key?(:'api_key_id') self.api_key_id = attributes[:'api_key_id'] end if attributes.key?(:'model') self.model = attributes[:'model'] end if attributes.key?(:'batch') self.batch = attributes[:'batch'] end end |
Instance Attribute Details
#api_key_id ⇒ Object
When group_by=api_key_id, this field provides the API key ID of the grouped usage result.
46 47 48 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 46 def api_key_id @api_key_id end |
#batch ⇒ Object
When group_by=batch, this field tells whether the grouped usage result is batch or not.
52 53 54 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 52 def batch @batch end |
#input_audio_tokens ⇒ Object
The aggregated number of audio input tokens used, including cached tokens.
31 32 33 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 31 def input_audio_tokens @input_audio_tokens end |
#input_cached_tokens ⇒ Object
The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.
25 26 27 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 25 def input_cached_tokens @input_cached_tokens end |
#input_tokens ⇒ Object
The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.
22 23 24 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 22 def input_tokens @input_tokens end |
#model ⇒ Object
When group_by=model, this field provides the model name of the grouped usage result.
49 50 51 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 49 def model @model end |
#num_model_requests ⇒ Object
The count of requests made to the model.
37 38 39 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 37 def num_model_requests @num_model_requests end |
#object ⇒ Object
Returns the value of attribute object.
19 20 21 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 19 def object @object end |
#output_audio_tokens ⇒ Object
The aggregated number of audio output tokens used.
34 35 36 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 34 def output_audio_tokens @output_audio_tokens end |
#output_tokens ⇒ Object
The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.
28 29 30 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 28 def output_tokens @output_tokens end |
#project_id ⇒ Object
When group_by=project_id, this field provides the project ID of the grouped usage result.
40 41 42 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 40 def project_id @project_id end |
#user_id ⇒ Object
When group_by=user_id, this field provides the user ID of the grouped usage result.
43 44 45 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 43 def user_id @user_id end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
95 96 97 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 95 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
100 101 102 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 100 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 77 def self.attribute_map { :'object' => :'object', :'input_tokens' => :'input_tokens', :'input_cached_tokens' => :'input_cached_tokens', :'output_tokens' => :'output_tokens', :'input_audio_tokens' => :'input_audio_tokens', :'output_audio_tokens' => :'output_audio_tokens', :'num_model_requests' => :'num_model_requests', :'project_id' => :'project_id', :'user_id' => :'user_id', :'api_key_id' => :'api_key_id', :'model' => :'model', :'batch' => :'batch' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 317 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_nullable ⇒ Object
List of attributes with nullable: true
123 124 125 126 127 128 129 130 131 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 123 def self.openapi_nullable Set.new([ :'project_id', :'user_id', :'api_key_id', :'model', :'batch' ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 105 def self.openapi_types { :'object' => :'String', :'input_tokens' => :'Integer', :'input_cached_tokens' => :'Integer', :'output_tokens' => :'Integer', :'input_audio_tokens' => :'Integer', :'output_audio_tokens' => :'Integer', :'num_model_requests' => :'Integer', :'project_id' => :'String', :'user_id' => :'String', :'api_key_id' => :'String', :'model' => :'String', :'batch' => :'Boolean' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 285 def ==(o) return true if self.equal?(o) self.class == o.class && object == o.object && input_tokens == o.input_tokens && input_cached_tokens == o.input_cached_tokens && output_tokens == o.output_tokens && input_audio_tokens == o.input_audio_tokens && output_audio_tokens == o.output_audio_tokens && num_model_requests == o.num_model_requests && project_id == o.project_id && user_id == o.user_id && api_key_id == o.api_key_id && model == o.model && batch == o.batch end |
#eql?(o) ⇒ Boolean
304 305 306 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 304 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
310 311 312 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 310 def hash [object, input_tokens, input_cached_tokens, output_tokens, input_audio_tokens, output_audio_tokens, num_model_requests, project_id, user_id, api_key_id, model, batch].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 208 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if @object.nil? invalid_properties.push('invalid value for "object", object cannot be nil.') end if @input_tokens.nil? invalid_properties.push('invalid value for "input_tokens", input_tokens cannot be nil.') end if @output_tokens.nil? invalid_properties.push('invalid value for "output_tokens", output_tokens cannot be nil.') end if @num_model_requests.nil? invalid_properties.push('invalid value for "num_model_requests", num_model_requests cannot be nil.') end invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 339 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
232 233 234 235 236 237 238 239 240 241 |
# File 'lib/openapi_openai/models/usage_completions_result.rb', line 232 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @object.nil? object_validator = EnumAttributeValidator.new('String', ["organization.usage.completions.result"]) return false unless object_validator.valid?(@object) return false if @input_tokens.nil? return false if @output_tokens.nil? return false if @num_model_requests.nil? true end |