class Riffer::StreamEvents::FinishReasonDone
Normalized reason the LLM finished, emitted once near the end of the stream; no ordering guarantee relative to TokenUsageDone.
Attributes
The normalized finish reason (see Riffer::Providers::FinishReason::VALUES).
The providerโs raw finish-reason value, when one exists on the wire.
Public Class Methods
Source
# File lib/riffer/stream_events/finish_reason_done.rb, line 17 def initialize(finish_reason:, raw_finish_reason: nil, role: :assistant) unless Riffer::Providers::FinishReason::VALUES.include?(finish_reason) raise Riffer::ArgumentError, "finish_reason must be one of #{Riffer::Providers::FinishReason::VALUES.inspect}, got #{finish_reason.inspect}" end super(role: role) @finish_reason = finish_reason @raw_finish_reason = raw_finish_reason end
Raises Riffer::ArgumentError when finish_reason is outside the normalized vocabulary.
Calls superclass method
Riffer::StreamEvents::Base::new
Public Instance Methods
Source
# File lib/riffer/stream_events/finish_reason_done.rb, line 29 def to_h hash = {role: @role, finish_reason: @finish_reason} #: Hash[Symbol, untyped] hash[:raw_finish_reason] = @raw_finish_reason if @raw_finish_reason hash end