Class: Riffer::StreamEvents::TextDelta
- Defined in:
- lib/riffer/stream_events/text_delta.rb
Overview
Represents an incremental text chunk during streaming.
Emitted when the LLM produces text content incrementally.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
The incremental text content.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(content, role: :assistant) ⇒ TextDelta
constructor
Creates a new text delta event.
-
#to_h ⇒ Object
Converts the event to a hash.
Constructor Details
#initialize(content, role: :assistant) ⇒ TextDelta
Creates a new text delta event.
- content
-
String - the incremental text content
- role
-
Symbol - the message role (defaults to :assistant)
16 17 18 19 |
# File 'lib/riffer/stream_events/text_delta.rb', line 16 def initialize(content, role: :assistant) super(role: role) @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
The incremental text content.
Returns String.
10 11 12 |
# File 'lib/riffer/stream_events/text_delta.rb', line 10 def content @content end |
Instance Method Details
#to_h ⇒ Object
Converts the event to a hash.
Returns Hash with :role and :content keys.
24 25 26 |
# File 'lib/riffer/stream_events/text_delta.rb', line 24 def to_h {role: @role, content: @content} end |