Class: Riffer::StreamEvents::FinishReasonDone
- Defined in:
- lib/riffer/stream_events/finish_reason_done.rb
Overview
Normalized reason the LLM finished, emitted once near the end of the stream; no ordering guarantee relative to TokenUsageDone.
Instance Attribute Summary collapse
-
#finish_reason ⇒ Object
readonly
The normalized finish reason (see
Riffer::Providers::FinishReason::VALUES). -
#raw_finish_reason ⇒ Object
readonly
The provider’s raw finish-reason value, when one exists on the wire.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(finish_reason:, raw_finish_reason: nil, role: :assistant) ⇒ FinishReasonDone
constructor
Raises Riffer::ArgumentError when
finish_reasonis outside the normalized vocabulary. -
#to_h ⇒ Object
– : () -> Hash[Symbol, untyped].
Constructor Details
#initialize(finish_reason:, raw_finish_reason: nil, role: :assistant) ⇒ FinishReasonDone
Raises Riffer::ArgumentError when finish_reason is outside the normalized vocabulary. – : (finish_reason: Symbol, ?raw_finish_reason: String?, ?role: Symbol) -> void
17 18 19 20 21 22 23 24 25 |
# 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 |
Instance Attribute Details
#finish_reason ⇒ Object (readonly)
The normalized finish reason (see Riffer::Providers::FinishReason::VALUES).
8 9 10 |
# File 'lib/riffer/stream_events/finish_reason_done.rb', line 8 def finish_reason @finish_reason end |
#raw_finish_reason ⇒ Object (readonly)
The provider’s raw finish-reason value, when one exists on the wire.
11 12 13 |
# File 'lib/riffer/stream_events/finish_reason_done.rb', line 11 def raw_finish_reason @raw_finish_reason end |
Instance Method Details
#to_h ⇒ Object
– : () -> Hash[Symbol, untyped]
29 30 31 32 33 |
# 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 |