Class: LlmCostTracker::UsageBreakdown
- Inherits:
-
Data
- Object
- Data
- LlmCostTracker::UsageBreakdown
- Defined in:
- lib/llm_cost_tracker/usage_breakdown.rb
Instance Attribute Summary collapse
-
#cache_read_input_tokens ⇒ Object
readonly
Returns the value of attribute cache_read_input_tokens.
-
#cache_write_input_tokens ⇒ Object
readonly
Returns the value of attribute cache_write_input_tokens.
-
#hidden_output_tokens ⇒ Object
readonly
Returns the value of attribute hidden_output_tokens.
-
#input_tokens ⇒ Object
readonly
Returns the value of attribute input_tokens.
-
#output_tokens ⇒ Object
readonly
Returns the value of attribute output_tokens.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#cache_read_input_tokens ⇒ Object (readonly)
Returns the value of attribute cache_read_input_tokens
4 5 6 |
# File 'lib/llm_cost_tracker/usage_breakdown.rb', line 4 def cache_read_input_tokens @cache_read_input_tokens end |
#cache_write_input_tokens ⇒ Object (readonly)
Returns the value of attribute cache_write_input_tokens
4 5 6 |
# File 'lib/llm_cost_tracker/usage_breakdown.rb', line 4 def cache_write_input_tokens @cache_write_input_tokens end |
#hidden_output_tokens ⇒ Object (readonly)
Returns the value of attribute hidden_output_tokens
4 5 6 |
# File 'lib/llm_cost_tracker/usage_breakdown.rb', line 4 def hidden_output_tokens @hidden_output_tokens end |
#input_tokens ⇒ Object (readonly)
Returns the value of attribute input_tokens
4 5 6 |
# File 'lib/llm_cost_tracker/usage_breakdown.rb', line 4 def input_tokens @input_tokens end |
#output_tokens ⇒ Object (readonly)
Returns the value of attribute output_tokens
4 5 6 |
# File 'lib/llm_cost_tracker/usage_breakdown.rb', line 4 def output_tokens @output_tokens end |
Class Method Details
.build(input_tokens:, output_tokens:, cache_read_input_tokens: 0, cache_write_input_tokens: 0, hidden_output_tokens: 0) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/llm_cost_tracker/usage_breakdown.rb', line 11 def self.build(input_tokens:, output_tokens:, cache_read_input_tokens: 0, cache_write_input_tokens: 0, hidden_output_tokens: 0) new( input_tokens: input_tokens.to_i, cache_read_input_tokens: cache_read_input_tokens.to_i, cache_write_input_tokens: cache_write_input_tokens.to_i, output_tokens: output_tokens.to_i, hidden_output_tokens: hidden_output_tokens.to_i ) end |
Instance Method Details
#to_h ⇒ Object
26 27 28 |
# File 'lib/llm_cost_tracker/usage_breakdown.rb', line 26 def to_h super.merge(total_tokens: total_tokens).compact end |
#total_tokens ⇒ Object
22 23 24 |
# File 'lib/llm_cost_tracker/usage_breakdown.rb', line 22 def total_tokens input_tokens + cache_read_input_tokens + cache_write_input_tokens + output_tokens end |