Class: LlmCostTracker::ParsedUsage
- Inherits:
-
Data
- Object
- Data
- LlmCostTracker::ParsedUsage
- Defined in:
- lib/llm_cost_tracker/parsed_usage.rb,
lib/llm_cost_tracker/parsed_usage.rb
Constant Summary collapse
- TRACKING_KEYS =
%i[provider model input_tokens output_tokens total_tokens].freeze
Instance Attribute Summary collapse
-
#cache_creation_input_tokens ⇒ Object
readonly
Returns the value of attribute cache_creation_input_tokens.
-
#cache_read_input_tokens ⇒ Object
readonly
Returns the value of attribute cache_read_input_tokens.
-
#cached_input_tokens ⇒ Object
readonly
Returns the value of attribute cached_input_tokens.
-
#input_tokens ⇒ Object
readonly
Returns the value of attribute input_tokens.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#output_tokens ⇒ Object
readonly
Returns the value of attribute output_tokens.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#reasoning_tokens ⇒ Object
readonly
Returns the value of attribute reasoning_tokens.
-
#total_tokens ⇒ Object
readonly
Returns the value of attribute total_tokens.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#cache_creation_input_tokens ⇒ Object (readonly)
Returns the value of attribute cache_creation_input_tokens
4 5 6 |
# File 'lib/llm_cost_tracker/parsed_usage.rb', line 4 def cache_creation_input_tokens @cache_creation_input_tokens end |
#cache_read_input_tokens ⇒ Object (readonly)
Returns the value of attribute cache_read_input_tokens
4 5 6 |
# File 'lib/llm_cost_tracker/parsed_usage.rb', line 4 def cache_read_input_tokens @cache_read_input_tokens end |
#cached_input_tokens ⇒ Object (readonly)
Returns the value of attribute cached_input_tokens
4 5 6 |
# File 'lib/llm_cost_tracker/parsed_usage.rb', line 4 def cached_input_tokens @cached_input_tokens end |
#input_tokens ⇒ Object (readonly)
Returns the value of attribute input_tokens
4 5 6 |
# File 'lib/llm_cost_tracker/parsed_usage.rb', line 4 def input_tokens @input_tokens end |
#model ⇒ Object (readonly)
Returns the value of attribute model
4 5 6 |
# File 'lib/llm_cost_tracker/parsed_usage.rb', line 4 def model @model end |
#output_tokens ⇒ Object (readonly)
Returns the value of attribute output_tokens
4 5 6 |
# File 'lib/llm_cost_tracker/parsed_usage.rb', line 4 def output_tokens @output_tokens end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider
4 5 6 |
# File 'lib/llm_cost_tracker/parsed_usage.rb', line 4 def provider @provider end |
#reasoning_tokens ⇒ Object (readonly)
Returns the value of attribute reasoning_tokens
4 5 6 |
# File 'lib/llm_cost_tracker/parsed_usage.rb', line 4 def reasoning_tokens @reasoning_tokens end |
#total_tokens ⇒ Object (readonly)
Returns the value of attribute total_tokens
4 5 6 |
# File 'lib/llm_cost_tracker/parsed_usage.rb', line 4 def total_tokens @total_tokens end |
Class Method Details
.build(**attributes) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/llm_cost_tracker/parsed_usage.rb', line 19 def self.build(**attributes) new( provider: attributes.fetch(:provider), model: attributes.fetch(:model), input_tokens: attributes.fetch(:input_tokens).to_i, output_tokens: attributes.fetch(:output_tokens).to_i, total_tokens: attributes.fetch(:total_tokens, 0).to_i, cached_input_tokens: attributes[:cached_input_tokens], cache_read_input_tokens: attributes[:cache_read_input_tokens], cache_creation_input_tokens: attributes[:cache_creation_input_tokens], reasoning_tokens: attributes[:reasoning_tokens] ) end |
Instance Method Details
#metadata ⇒ Object
33 34 35 |
# File 'lib/llm_cost_tracker/parsed_usage.rb', line 33 def to_h.except(*TRACKING_KEYS) end |
#to_h ⇒ Object
37 38 39 |
# File 'lib/llm_cost_tracker/parsed_usage.rb', line 37 def to_h super.compact end |