Class: VoyageAI::Usage

Inherits:
Object
  • Object
show all
Defined in:
lib/voyageai/usage.rb

Overview

The usage returned by the VoyageAI API.

Examples:

VoyageAI::Usage.new(total_tokens: 0)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(total_tokens:) ⇒ Usage

Returns a new instance of Usage.

Parameters:

  • total_tokens (Integer)


14
15
16
# File 'lib/voyageai/usage.rb', line 14

def initialize(total_tokens:)
  @total_tokens = total_tokens
end

Instance Attribute Details

#total_tokensInteger

Returns:

  • (Integer)


11
12
13
# File 'lib/voyageai/usage.rb', line 11

def total_tokens
  @total_tokens
end

Class Method Details

.parse(data:) ⇒ Usage

Parameters:

  • data (Hash)

Returns:



25
26
27
# File 'lib/voyageai/usage.rb', line 25

def self.parse(data:)
  new(total_tokens: data["total_tokens"])
end

Instance Method Details

#inspectString

Returns:

  • (String)


19
20
21
# File 'lib/voyageai/usage.rb', line 19

def inspect
  "#<#{self.class.name} total_tokens=#{total_tokens}>"
end