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 17 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).
: (Riffer::Guardrails::Modification, ?role: Symbol) -> void
Calls superclass method
Riffer::StreamEvents::Base::new
Public Instance Methods
Source
# File lib/riffer/stream_events/guardrail_modification.rb, line 25 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.
: () -> singleton(Riffer::Guardrail)
Source
# File lib/riffer/stream_events/guardrail_modification.rb, line 35 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.
: () -> Array
Source
# File lib/riffer/stream_events/guardrail_modification.rb, line 30 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.
: () -> Symbol
Source
# File lib/riffer/stream_events/guardrail_modification.rb, line 40 def to_h {role: @role, modification: modification.to_h} end
Converts the event to a hash.
: () -> Hash[Symbol, untyped]