Class: LlmCostTracker::UsageCapture
- Inherits:
-
Data
- Object
- Data
- LlmCostTracker::UsageCapture
- Defined in:
- lib/llm_cost_tracker/usage_capture.rb,
lib/llm_cost_tracker/usage_capture.rb
Constant Summary collapse
- UNKNOWN_MODEL =
"unknown"
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#pricing_mode ⇒ Object
readonly
Returns the value of attribute pricing_mode.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#provider_response_id ⇒ Object
readonly
Returns the value of attribute provider_response_id.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
-
#token_usage ⇒ Object
readonly
Returns the value of attribute token_usage.
-
#usage_source ⇒ Object
readonly
Returns the value of attribute usage_source.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model
8 9 10 |
# File 'lib/llm_cost_tracker/usage_capture.rb', line 8 def model @model end |
#pricing_mode ⇒ Object (readonly)
Returns the value of attribute pricing_mode
8 9 10 |
# File 'lib/llm_cost_tracker/usage_capture.rb', line 8 def pricing_mode @pricing_mode end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider
8 9 10 |
# File 'lib/llm_cost_tracker/usage_capture.rb', line 8 def provider @provider end |
#provider_response_id ⇒ Object (readonly)
Returns the value of attribute provider_response_id
8 9 10 |
# File 'lib/llm_cost_tracker/usage_capture.rb', line 8 def provider_response_id @provider_response_id end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream
8 9 10 |
# File 'lib/llm_cost_tracker/usage_capture.rb', line 8 def stream @stream end |
#token_usage ⇒ Object (readonly)
Returns the value of attribute token_usage
8 9 10 |
# File 'lib/llm_cost_tracker/usage_capture.rb', line 8 def token_usage @token_usage end |
#usage_source ⇒ Object (readonly)
Returns the value of attribute usage_source
8 9 10 |
# File 'lib/llm_cost_tracker/usage_capture.rb', line 8 def usage_source @usage_source end |
Class Method Details
.build(**attributes) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/llm_cost_tracker/usage_capture.rb', line 21 def self.build(**attributes) new( provider: attributes.fetch(:provider).to_s, model: attributes.fetch(:model).to_s.strip.presence || UNKNOWN_MODEL, token_usage: attributes.fetch(:token_usage), stream: attributes[:stream] || false, usage_source: attributes[:usage_source], provider_response_id: attributes[:provider_response_id], pricing_mode: Pricing.normalize_mode(attributes[:pricing_mode]) ) end |
Instance Method Details
#to_h ⇒ Object
33 34 35 |
# File 'lib/llm_cost_tracker/usage_capture.rb', line 33 def to_h super.compact end |