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]. An :agent_stream event wraps a copied, frozen Agent
event with an
AgentStreamSource when a Run exposes
nested work.
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 event with a symbol
typeand frozen outer payload Hash.
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data
4 5 6 |
# File 'lib/little_ghost/stream_event.rb', line 4 def data @data end |
#type ⇒ Object (readonly)
Returns the value of attribute type
4 5 6 |
# File 'lib/little_ghost/stream_event.rb', line 4 def type @type end |
Class Method Details
.build(type, **data) ⇒ Object
Creates an event with a symbol type and frozen outer payload Hash.
6 7 8 |
# File 'lib/little_ghost/stream_event.rb', line 6 def self.build(type, **data) new(type: type.to_sym, data: data.freeze) end |