Class: LittleGhost::StreamEvent

Inherits:
Data
  • Object
show all
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

Class Method Summary collapse

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



13
14
15
# File 'lib/little_ghost/stream_event.rb', line 13

def data
  @data
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of 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