Class: AssemblyAI::Lemur::LemurUsage

Inherits:
Object
  • Object
show all
Defined in:
lib/assemblyai/lemur/types/lemur_usage.rb

Overview

The usage numbers for the LeMUR request

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_tokens:, output_tokens:, additional_properties: nil) ⇒ AssemblyAI::Lemur::LemurUsage

Parameters:

  • input_tokens (Integer)

    The number of input tokens used by the model

  • output_tokens (Integer)

    The number of output tokens generated by the model

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



26
27
28
29
30
31
# File 'lib/assemblyai/lemur/types/lemur_usage.rb', line 26

def initialize(input_tokens:, output_tokens:, additional_properties: nil)
  @input_tokens = input_tokens
  @output_tokens = output_tokens
  @additional_properties = additional_properties
  @_field_set = { "input_tokens": input_tokens, "output_tokens": output_tokens }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



15
16
17
# File 'lib/assemblyai/lemur/types/lemur_usage.rb', line 15

def additional_properties
  @additional_properties
end

#input_tokensInteger (readonly)

Returns The number of input tokens used by the model.

Returns:

  • (Integer)

    The number of input tokens used by the model



11
12
13
# File 'lib/assemblyai/lemur/types/lemur_usage.rb', line 11

def input_tokens
  @input_tokens
end

#output_tokensInteger (readonly)

Returns The number of output tokens generated by the model.

Returns:

  • (Integer)

    The number of output tokens generated by the model



13
14
15
# File 'lib/assemblyai/lemur/types/lemur_usage.rb', line 13

def output_tokens
  @output_tokens
end

Class Method Details

.from_json(json_object:) ⇒ AssemblyAI::Lemur::LemurUsage

Deserialize a JSON object to an instance of LemurUsage

Parameters:

  • json_object (String)

Returns:



37
38
39
40
41
42
43
44
45
46
# File 'lib/assemblyai/lemur/types/lemur_usage.rb', line 37

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  input_tokens = struct["input_tokens"]
  output_tokens = struct["output_tokens"]
  new(
    input_tokens: input_tokens,
    output_tokens: output_tokens,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


61
62
63
64
# File 'lib/assemblyai/lemur/types/lemur_usage.rb', line 61

def self.validate_raw(obj:)
  obj.input_tokens.is_a?(Integer) != false || raise("Passed value for field obj.input_tokens is not the expected type, validation failed.")
  obj.output_tokens.is_a?(Integer) != false || raise("Passed value for field obj.output_tokens is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of LemurUsage to a JSON object

Returns:

  • (String)


51
52
53
# File 'lib/assemblyai/lemur/types/lemur_usage.rb', line 51

def to_json(*_args)
  @_field_set&.to_json
end