Class: TurnKit::Usage
- Inherits:
-
Object
- Object
- TurnKit::Usage
- Defined in:
- lib/turnkit/usage.rb
Instance Attribute Summary collapse
-
#cached_tokens ⇒ Object
readonly
Returns the value of attribute cached_tokens.
-
#cost ⇒ Object
readonly
Returns the value of attribute cost.
-
#input_tokens ⇒ Object
readonly
Returns the value of attribute input_tokens.
-
#output_tokens ⇒ Object
readonly
Returns the value of attribute output_tokens.
Instance Method Summary collapse
-
#initialize(input_tokens: 0, output_tokens: 0, cached_tokens: 0, cost: nil) ⇒ Usage
constructor
A new instance of Usage.
- #to_h ⇒ Object
- #total_tokens ⇒ Object
Constructor Details
#initialize(input_tokens: 0, output_tokens: 0, cached_tokens: 0, cost: nil) ⇒ Usage
Returns a new instance of Usage.
7 8 9 10 11 12 |
# File 'lib/turnkit/usage.rb', line 7 def initialize(input_tokens: 0, output_tokens: 0, cached_tokens: 0, cost: nil) @input_tokens = input_tokens.to_i @output_tokens = output_tokens.to_i @cached_tokens = cached_tokens.to_i @cost = cost end |
Instance Attribute Details
#cached_tokens ⇒ Object (readonly)
Returns the value of attribute cached_tokens.
5 6 7 |
# File 'lib/turnkit/usage.rb', line 5 def cached_tokens @cached_tokens end |
#cost ⇒ Object (readonly)
Returns the value of attribute cost.
5 6 7 |
# File 'lib/turnkit/usage.rb', line 5 def cost @cost end |
#input_tokens ⇒ Object (readonly)
Returns the value of attribute input_tokens.
5 6 7 |
# File 'lib/turnkit/usage.rb', line 5 def input_tokens @input_tokens end |
#output_tokens ⇒ Object (readonly)
Returns the value of attribute output_tokens.
5 6 7 |
# File 'lib/turnkit/usage.rb', line 5 def output_tokens @output_tokens end |
Instance Method Details
#to_h ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/turnkit/usage.rb', line 18 def to_h { "input_tokens" => input_tokens, "output_tokens" => output_tokens, "cached_tokens" => cached_tokens, "total_tokens" => total_tokens, "cost" => cost }.compact end |
#total_tokens ⇒ Object
14 15 16 |
# File 'lib/turnkit/usage.rb', line 14 def total_tokens input_tokens + output_tokens + cached_tokens end |