Class: LittleGhost::StreamEvent
- Inherits:
-
Data
- Object
- Data
- LittleGhost::StreamEvent
- Defined in:
- lib/little_ghost/stream_event.rb,
lib/little_ghost/stream_event.rb
Overview
StreamEvent gives every provider and interface the same language for live agent output. Consumers can handle text, reasoning, tools, usage, retries, and completion without branching on a provider SDK.
Providers emit events such as :message_start, :text_delta,
:reasoning_delta, :tool_call_start, :tool_call_delta,
:tool_call_stop, :usage, :model_retry, and :message_stop. The
terminal event carries a ModelResponse
in data[:response].
event = LittleGhost::StreamEvent.build(:text_delta, text: "Hello")
event.type # => :text_delta
event.data[:text] # => "Hello"
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.build(type, **data) ⇒ Object
Creates an immutable event with a symbol
typeand keyword payload.
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data
13 14 15 |
# File 'lib/little_ghost/stream_event.rb', line 13 def data @data end |
#type ⇒ Object (readonly)
Returns the value of attribute type
13 14 15 |
# File 'lib/little_ghost/stream_event.rb', line 13 def type @type end |
Class Method Details
.build(type, **data) ⇒ Object
Creates an immutable event with a symbol type and keyword payload.
15 16 17 |
# File 'lib/little_ghost/stream_event.rb', line 15 def self.build(type, **data) new(type: type.to_sym, data: data.freeze) end |