Class: AgUiProtocol::Core::Events::TextMessageStartEvent

Inherits:
BaseEvent show all
Defined in:
lib/ag_ui_protocol/core/events.rb

Overview

Signals the start of a text message.

“‘ruby

event = AgUiProtocol::Core::Events::TextMessageStartEvent.new(

message_id: "m1",

)

“‘

Instance Attribute Summary collapse

Attributes inherited from BaseEvent

#raw_event, #timestamp, #type

Instance Method Summary collapse

Methods inherited from Types::Model

#as_json, #to_json

Constructor Details

#initialize(message_id:, timestamp: nil, raw_event: nil) ⇒ TextMessageStartEvent

Returns a new instance of TextMessageStartEvent.



128
129
130
131
132
# File 'lib/ag_ui_protocol/core/events.rb', line 128

def initialize(message_id:, timestamp: nil, raw_event: nil)
  super(type: EventType::TEXT_MESSAGE_START, timestamp: timestamp, raw_event: raw_event)
  @message_id = message_id
  @role = 'assistant'
end

Instance Attribute Details

#message_idObject (readonly)

Returns the value of attribute message_id.



119
120
121
# File 'lib/ag_ui_protocol/core/events.rb', line 119

def message_id
  @message_id
end

#roleObject (readonly)

Returns the value of attribute role.



122
123
124
# File 'lib/ag_ui_protocol/core/events.rb', line 122

def role
  @role
end

Instance Method Details

#to_hObject



135
136
137
# File 'lib/ag_ui_protocol/core/events.rb', line 135

def to_h
  super.merge(message_id: @message_id, role: @role)
end