Class: Riffer::StreamEvents::GuardrailModification
- Defined in:
- lib/riffer/stream_events/guardrail_modification.rb
Overview
Represents a guardrail modification event during streaming.
Emitted when a guardrail transforms data during the streaming pipeline.
Instance Attribute Summary collapse
-
#modification ⇒ Object
readonly
The modification record.
Attributes inherited from Base
Instance Method Summary collapse
-
#guardrail ⇒ Object
The guardrail class that made the transformation.
-
#initialize(modification, role: :assistant) ⇒ GuardrailModification
constructor
Creates a new guardrail modification stream event.
-
#message_indices ⇒ Object
The indices of messages that were changed.
-
#phase ⇒ Object
The phase when the transformation occurred.
-
#to_h ⇒ Object
Converts the event to a hash.
Constructor Details
#initialize(modification, role: :assistant) ⇒ GuardrailModification
Creates a new guardrail modification stream event.
- modification
-
the modification details.
- role
-
the message role (defaults to :assistant).
– : (Riffer::Guardrails::Modification, ?role: Symbol) -> void
18 19 20 21 |
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 18 def initialize(modification, role: :assistant) super(role: role) @modification = modification end |
Instance Attribute Details
#modification ⇒ Object (readonly)
The modification record.
9 10 11 |
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 9 def modification @modification end |
Instance Method Details
#guardrail ⇒ Object
The guardrail class that made the transformation.
– : () -> singleton(Riffer::Guardrail)
27 |
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 27 def guardrail = modification.guardrail |
#message_indices ⇒ Object
The indices of messages that were changed.
– : () -> Array
39 |
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 39 def = modification. |
#phase ⇒ Object
The phase when the transformation occurred.
– : () -> Symbol
33 |
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 33 def phase = modification.phase |
#to_h ⇒ Object
Converts the event to a hash.
– : () -> Hash[Symbol, untyped]
45 46 47 |
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 45 def to_h {role: @role, modification: modification.to_h} end |