Class: Riffer::StreamEvents::TextDone

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

Overview

Represents completion of text generation during streaming.

Emitted when the LLM has finished producing text content.

Instance Attribute Summary collapse

Attributes inherited from Base

#role

Instance Method Summary collapse

Constructor Details

#initialize(content, role: :assistant) ⇒ TextDone

Creates a new text done event.

content

String - the complete text content

role

Symbol - the message role (defaults to :assistant)



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

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

Instance Attribute Details

#contentObject (readonly)

The complete text content.

Returns String.



10
11
12
# File 'lib/riffer/stream_events/text_done.rb', line 10

def content
  @content
end

Instance Method Details

#to_hObject

Converts the event to a hash.

Returns Hash with :role and :content keys.



24
25
26
# File 'lib/riffer/stream_events/text_done.rb', line 24

def to_h
  {role: @role, content: @content}
end