Class: Riffer::StreamEvents::GuardrailModification

Inherits:
Base
  • Object
show all
Defined in:
lib/riffer/stream_events/guardrail_modification.rb,
sig/generated/riffer/stream_events/guardrail_modification.rbs

Overview

Emitted when a guardrail transforms data during streaming.

Instance Attribute Summary collapse

Attributes inherited from Base

#role

Instance Method Summary collapse

Constructor Details

#initialize(modification, role: :assistant) ⇒ GuardrailModification

-- : (Riffer::Guardrails::Modification, ?role: Symbol) -> void

Parameters:



11
12
13
14
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 11

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

Instance Attribute Details

#modificationRiffer::Guardrails::Modification (readonly)

The modification record.



7
8
9
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 7

def modification
  @modification
end

Instance Method Details

#guardrailsingleton(Riffer::Guardrail)

The guardrail class that made the transformation.

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

Returns:



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

def guardrail = modification.guardrail

#message_indicesArray[Integer]

The indices of messages that were changed.

-- : () -> Array

Returns:

  • (Array[Integer])


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

def message_indices = modification.message_indices

#phaseSymbol

The phase when the transformation occurred.

-- : () -> Symbol

Returns:

  • (Symbol)


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

def phase = modification.phase

#to_hHash[Symbol, untyped]

Converts the event to a hash.

-- : () -> Hash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


38
39
40
# File 'lib/riffer/stream_events/guardrail_modification.rb', line 38

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