Class: Riffer::StreamEvents::GuardrailModification

Inherits:
Base
  • Object
show all
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

Attributes inherited from Base

#role

Instance Method Summary collapse

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



17
18
19
20
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 17

def initialize(modification, role: :assistant)
  super(role: role)
  @modification = modification
end

Instance Attribute Details

#modificationObject (readonly)

The modification record.



9
10
11
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 9

def modification
  @modification
end

Instance Method Details

#guardrailObject

The guardrail class that made the transformation.

: () -> singleton(Riffer::Guardrail)



25
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 25

def guardrail = modification.guardrail

#message_indicesObject

The indices of messages that were changed.

: () -> Array



35
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 35

def message_indices = modification.message_indices

#phaseObject

The phase when the transformation occurred.

: () -> Symbol



30
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 30

def phase = modification.phase

#to_hObject

Converts the event to a hash.

: () -> Hash[Symbol, untyped]



40
41
42
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 40

def to_h
  {role: @role, modification: modification.to_h}
end