Class: Riffer::StreamEvents::GuardrailTripwire

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

Overview

Emitted when a guardrail blocks execution during streaming.

Instance Attribute Summary collapse

Attributes inherited from Base

#role

Instance Method Summary collapse

Constructor Details

#initialize(tripwire, role: :assistant) ⇒ GuardrailTripwire

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

Parameters:



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

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

Instance Attribute Details

#tripwireRiffer::Guardrails::Tripwire (readonly)

The tripwire containing block details.



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

def tripwire
  @tripwire
end

Instance Method Details

#guardrailsingleton(Riffer::Guardrail)

The guardrail class that triggered the block.

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

Returns:



36
37
38
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 36

def guardrail
  tripwire.guardrail
end

#phaseSymbol

The phase when blocking occurred (:before or :after).

-- : () -> Symbol

Returns:

  • (Symbol)


28
29
30
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 28

def phase
  tripwire.phase
end

#reasonString

The reason for blocking.

-- : () -> String

Returns:

  • (String)


20
21
22
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 20

def reason
  tripwire.reason
end

#to_hHash[Symbol, untyped]

Converts the event to a hash.

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

Returns:

  • (Hash[Symbol, untyped])


44
45
46
47
48
49
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 44

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