class Riffer::StreamEvents::GuardrailModification
Represents a guardrail modification event during streaming.
Emitted when a guardrail transforms data during the streaming pipeline.
Attributes
The modification record.
Public Class Methods
Source
# File lib/riffer/stream_events/guardrail_modification.rb, line 18 def initialize(modification, role: :assistant) super(role: role) @modification = modification end
Creates a new guardrail modification stream event.
- modification
-
the modification details.
- role
-
the message role (defaults to :assistant).
Calls superclass method
Riffer::StreamEvents::Base::new
Public Instance Methods
Source
# File lib/riffer/stream_events/guardrail_modification.rb, line 27 def guardrail = modification.guardrail # The phase when the transformation occurred. # #-- #: () -> Symbol def phase = modification.phase # The indices of messages that were changed. # #-- #: () -> Array[Integer] def message_indices = modification.message_indices # Converts the event to a hash. # #-- #: () -> Hash[Symbol, untyped] def to_h {role: @role, modification: modification.to_h}
The guardrail class that made the transformation.
Source
# File lib/riffer/stream_events/guardrail_modification.rb, line 39 def message_indices = modification.message_indices # Converts the event to a hash. # #-- #: () -> Hash[Symbol, untyped] def to_h {role: @role, modification: modification.to_h} end end
The indices of messages that were changed.
Source
# File lib/riffer/stream_events/guardrail_modification.rb, line 33 def phase = modification.phase # The indices of messages that were changed. # #-- #: () -> Array[Integer] def message_indices = modification.message_indices # Converts the event to a hash. # #-- #: () -> Hash[Symbol, untyped] def to_h {role: @role, modification: modification.to_h} end
The phase when the transformation occurred.
Source
# File lib/riffer/stream_events/guardrail_modification.rb, line 45 def to_h {role: @role, modification: modification.to_h} end
Converts the event to a hash.