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