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_id ⇒ Object
The guardrail identifier 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
17 18 19 20 |
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 17 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_id ⇒ Object
The guardrail identifier that triggered the block.
: () -> String
39 40 41 |
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 39 def guardrail_id tripwire.guardrail_id end |
#phase ⇒ Object
The phase when blocking occurred (:before or :after).
: () -> Symbol
32 33 34 |
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 32 def phase tripwire.phase end |
#reason ⇒ Object
The reason for blocking.
: () -> String
25 26 27 |
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 25 def reason tripwire.reason end |
#to_h ⇒ Object
Converts the event to a hash.
: () -> Hash[Symbol, untyped]
46 47 48 49 50 51 |
# File 'lib/riffer/stream_events/guardrail_tripwire.rb', line 46 def to_h { role: @role, tripwire: tripwire.to_h } end |