Class: Riffer::StreamEvents::Interrupt

Inherits:
Base
  • Object
show all
Defined in:
lib/riffer/stream_events/interrupt.rb

Overview

Represents an interrupt during streaming, fired when a callback throws :riffer_interrupt.

Instance Attribute Summary collapse

Attributes inherited from Base

#role

Instance Method Summary collapse

Constructor Details

#initialize(reason: nil, healed_tool_call_ids: []) ⇒ Interrupt

– : (?reason: (String | Symbol)?, ?healed_tool_call_ids: Array) -> void



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

def initialize(reason: nil, healed_tool_call_ids: [])
  super(role: :system)
  @reason = reason
  @healed_tool_call_ids = healed_tool_call_ids
end

Instance Attribute Details

#healed_tool_call_idsObject (readonly)

Call ids of tool_use blocks riffer filled with placeholder results when the interrupt fired (only when history healing is on).



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

def healed_tool_call_ids
  @healed_tool_call_ids
end

#reasonObject (readonly)

The reason provided with the interrupt, if any.



8
9
10
# File 'lib/riffer/stream_events/interrupt.rb', line 8

def reason
  @reason
end

Instance Method Details

#to_hObject

Converts the event to a hash. – : () -> Hash[Symbol, untyped]



25
26
27
28
29
30
# File 'lib/riffer/stream_events/interrupt.rb', line 25

def to_h
  h = {role: @role, interrupt: true} #: Hash[Symbol, untyped]
  h[:reason] = @reason if @reason
  h[:healed_tool_call_ids] = @healed_tool_call_ids unless @healed_tool_call_ids.empty?
  h
end