Class: Riffer::StreamEvents::TokenUsageDone

Inherits:
Base
  • Object
show all
Defined in:
lib/riffer/stream_events/token_usage_done.rb

Overview

Final token usage for the response, emitted when the LLM finishes.

Instance Attribute Summary collapse

Attributes inherited from Base

#role

Instance Method Summary collapse

Constructor Details

#initialize(token_usage:, role: :assistant) ⇒ TokenUsageDone

– : (token_usage: Riffer::Providers::TokenUsage, ?role: Symbol) -> void



11
12
13
14
# File 'lib/riffer/stream_events/token_usage_done.rb', line 11

def initialize(token_usage:, role: :assistant)
  super(role: role)
  @token_usage = token_usage
end

Instance Attribute Details

#token_usageObject (readonly)

The token usage data for this response.



7
8
9
# File 'lib/riffer/stream_events/token_usage_done.rb', line 7

def token_usage
  @token_usage
end

Instance Method Details

#to_hObject

– : () -> Hash[Symbol, untyped]



18
19
20
# File 'lib/riffer/stream_events/token_usage_done.rb', line 18

def to_h
  {role: @role, token_usage: @token_usage.to_h}
end