Class: Riffer::StreamEvents::GuardrailTripwire
- Defined in:
- lib/riffer/stream_events/guardrail_tripwire.rb
Overview
Represents a guardrail tripwire event during streaming.
Emitted when a guardrail blocks execution during the streaming pipeline.
Instance Attribute Summary collapse
-
#tripwire ⇒ Object
readonly
The tripwire containing block details.
Attributes inherited from Base
Instance Method Summary collapse
-
#guardrail ⇒ Object
The guardrail class that triggered the block.
-
#initialize(tripwire, role: :assistant) ⇒ GuardrailTripwire
constructor
Creates a new tripwire stream event.
-
#phase ⇒ Object
The phase when blocking occurred (:before or :after).
-
#reason ⇒ Object
The reason for blocking.
-
#to_h ⇒ Object
Converts the event to a hash.
Constructor Details
#initialize(tripwire, role: :assistant) ⇒ GuardrailTripwire
Creates a new tripwire stream event.
- tripwire
-
the tripwire details.
- role
-
the message role (defaults to :assistant).
– : (Riffer::Guardrails::Tripwire, ?role: Symbol) -> void
18 19 20 21 |
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 18 def initialize(tripwire, role: :assistant) super(role: role) @tripwire = tripwire end |
Instance Attribute Details
#tripwire ⇒ Object (readonly)
The tripwire containing block details.
9 10 11 |
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 9 def tripwire @tripwire end |
Instance Method Details
#guardrail ⇒ Object
The guardrail class that triggered the block.
– : () -> singleton(Riffer::Guardrail)
43 44 45 |
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 43 def guardrail tripwire.guardrail end |
#phase ⇒ Object
The phase when blocking occurred (:before or :after).
– : () -> Symbol
35 36 37 |
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 35 def phase tripwire.phase end |
#reason ⇒ Object
The reason for blocking.
– : () -> String
27 28 29 |
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 27 def reason tripwire.reason end |
#to_h ⇒ Object
Converts the event to a hash.
– : () -> Hash[Symbol, untyped]
51 52 53 54 55 56 |
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 51 def to_h { role: @role, tripwire: tripwire.to_h } end |