Class: AgUiProtocol::Core::Events::TextMessageChunkEvent
- Inherits:
-
BaseEvent
- Object
- Types::Model
- BaseEvent
- AgUiProtocol::Core::Events::TextMessageChunkEvent
- Defined in:
- lib/ag_ui_protocol/core/events.rb
Overview
Convenience event for complete text messages without manually emitting ‘TextMessageStart`/`TextMessageEnd`.
“‘ruby event = AgUiProtocol::Core::Events::TextMessageChunkEvent.new(
message_id: "m1",
delta: "Hello"
)
“‘
Behavior:
-
Convenience: Some consumers (e.g., the JS/TS client) expand chunk events into the standard start/content/end sequence automatically, allowing producers to omit explicit start/end events when using chunks.
-
First chunk requirements: The first chunk for a given message must include ‘message_id`.
-
Streaming: Subsequent chunks with the same ‘message_id` correspond to content pieces; completion triggers an implied end in clients that perform expansion.
Instance Attribute Summary collapse
-
#delta ⇒ Object
readonly
Returns the value of attribute delta.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Attributes inherited from BaseEvent
Instance Method Summary collapse
-
#initialize(message_id: nil, role: nil, delta: nil, timestamp: nil, raw_event: nil) ⇒ TextMessageChunkEvent
constructor
A new instance of TextMessageChunkEvent.
- #to_h ⇒ Object
Methods inherited from Types::Model
Constructor Details
#initialize(message_id: nil, role: nil, delta: nil, timestamp: nil, raw_event: nil) ⇒ TextMessageChunkEvent
Returns a new instance of TextMessageChunkEvent.
247 248 249 250 251 252 253 254 |
# File 'lib/ag_ui_protocol/core/events.rb', line 247 def initialize(message_id: nil, role: nil, delta: nil, timestamp: nil, raw_event: nil) raise ArgumentError, "role must be one of #{TEXT_MESSAGE_ROLE_VALUES.join(", ")}, got #{role}" if !role.nil? && !TEXT_MESSAGE_ROLE_VALUES.include?(role) super(type: EventType::TEXT_MESSAGE_CHUNK, timestamp: , raw_event: raw_event) @message_id = @role = role @delta = delta end |
Instance Attribute Details
#delta ⇒ Object (readonly)
Returns the value of attribute delta.
231 232 233 |
# File 'lib/ag_ui_protocol/core/events.rb', line 231 def delta @delta end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
225 226 227 |
# File 'lib/ag_ui_protocol/core/events.rb', line 225 def @message_id end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
228 229 230 |
# File 'lib/ag_ui_protocol/core/events.rb', line 228 def role @role end |
Instance Method Details
#to_h ⇒ Object
257 258 259 |
# File 'lib/ag_ui_protocol/core/events.rb', line 257 def to_h super.merge(message_id: @message_id, role: @role, delta: @delta) end |