Class: LlmCostTracker::Event
- Inherits:
-
Data
- Object
- Data
- LlmCostTracker::Event
- Defined in:
- lib/llm_cost_tracker/event.rb
Instance Attribute Summary collapse
-
#cost ⇒ Object
readonly
Returns the value of attribute cost.
-
#event_id ⇒ Object
readonly
Returns the value of attribute event_id.
-
#latency_ms ⇒ Object
readonly
Returns the value of attribute latency_ms.
-
#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.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#token_usage ⇒ Object
readonly
Returns the value of attribute token_usage.
-
#tracked_at ⇒ Object
readonly
Returns the value of attribute tracked_at.
-
#usage_source ⇒ Object
readonly
Returns the value of attribute usage_source.
Instance Method Summary collapse
Instance Attribute Details
#cost ⇒ Object (readonly)
Returns the value of attribute cost
4 5 6 |
# File 'lib/llm_cost_tracker/event.rb', line 4 def cost @cost end |
#event_id ⇒ Object (readonly)
Returns the value of attribute event_id
4 5 6 |
# File 'lib/llm_cost_tracker/event.rb', line 4 def event_id @event_id end |
#latency_ms ⇒ Object (readonly)
Returns the value of attribute latency_ms
4 5 6 |
# File 'lib/llm_cost_tracker/event.rb', line 4 def latency_ms @latency_ms end |
#model ⇒ Object (readonly)
Returns the value of attribute model
4 5 6 |
# File 'lib/llm_cost_tracker/event.rb', line 4 def model @model end |
#pricing_mode ⇒ Object (readonly)
Returns the value of attribute pricing_mode
4 5 6 |
# File 'lib/llm_cost_tracker/event.rb', line 4 def pricing_mode @pricing_mode end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider
4 5 6 |
# File 'lib/llm_cost_tracker/event.rb', line 4 def provider @provider end |
#provider_response_id ⇒ Object (readonly)
Returns the value of attribute provider_response_id
4 5 6 |
# File 'lib/llm_cost_tracker/event.rb', line 4 def provider_response_id @provider_response_id end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream
4 5 6 |
# File 'lib/llm_cost_tracker/event.rb', line 4 def stream @stream end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags
4 5 6 |
# File 'lib/llm_cost_tracker/event.rb', line 4 def @tags end |
#token_usage ⇒ Object (readonly)
Returns the value of attribute token_usage
4 5 6 |
# File 'lib/llm_cost_tracker/event.rb', line 4 def token_usage @token_usage end |
#tracked_at ⇒ Object (readonly)
Returns the value of attribute tracked_at
4 5 6 |
# File 'lib/llm_cost_tracker/event.rb', line 4 def tracked_at @tracked_at end |
#usage_source ⇒ Object (readonly)
Returns the value of attribute usage_source
4 5 6 |
# File 'lib/llm_cost_tracker/event.rb', line 4 def usage_source @usage_source end |
Instance Method Details
#to_h ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/llm_cost_tracker/event.rb', line 22 def to_h super.merge( token_usage: token_usage.to_h, cost: cost&.to_h, tags: ? .to_h : {} ) end |
#total_cost ⇒ Object
18 19 20 |
# File 'lib/llm_cost_tracker/event.rb', line 18 def total_cost cost&.fetch(:total_cost, nil) end |