Class: Riffer::StreamEvents::TokenUsageDone
- Defined in:
- lib/riffer/stream_events/token_usage_done.rb
Overview
Represents completion of token usage tracking during streaming.
Emitted when the LLM has finished and token usage data is available.
event.token_usage.input_tokens # => 100
event.token_usage.output_tokens # => 50
event.token_usage.total_tokens # => 150
Instance Attribute Summary collapse
-
#token_usage ⇒ Object
readonly
The token usage data for this response.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(token_usage:, role: :assistant) ⇒ TokenUsageDone
constructor
– : (token_usage: Riffer::TokenUsage, ?role: Symbol) -> void.
-
#to_h ⇒ Object
– : () -> Hash[Symbol, untyped].
Constructor Details
#initialize(token_usage:, role: :assistant) ⇒ TokenUsageDone
– : (token_usage: Riffer::TokenUsage, ?role: Symbol) -> void
18 19 20 21 |
# File 'lib/riffer/stream_events/token_usage_done.rb', line 18 def initialize(token_usage:, role: :assistant) super(role: role) @token_usage = token_usage end |
Instance Attribute Details
#token_usage ⇒ Object (readonly)
The token usage data for this response.
14 15 16 |
# File 'lib/riffer/stream_events/token_usage_done.rb', line 14 def token_usage @token_usage end |
Instance Method Details
#to_h ⇒ Object
– : () -> Hash[Symbol, untyped]
25 26 27 |
# File 'lib/riffer/stream_events/token_usage_done.rb', line 25 def to_h {role: @role, token_usage: @token_usage.to_h} end |