Class: HermesAgent::Client::Entities::ResponseStreamEvent
- Inherits:
-
HermesAgent::Client::Entity
- Object
- HermesAgent::Client::Entity
- HermesAgent::Client::Entities::ResponseStreamEvent
- Defined in:
- lib/hermes_agent/client/entities/response.rb
Overview
One event in a streamed Responses turn (Resources::Responses#stream_create).
The Responses API emits named SSE events; each payload repeats the
name in its #type and carries a 0-based #sequence_number. The
observed sequence for a simple turn is response.created →
response.output_item.added → response.output_text.delta (one per
delta) → response.output_text.done → response.output_item.done →
response.completed (terminal; there is no [DONE] sentinel). Which
readers are meaningful depends on #type; the rest return nil.
Instance Method Summary collapse
-
#content_index ⇒ Integer?
The index of the content part within the item this event applies to.
-
#delta ⇒ String?
The incremental text on a
response.output_text.deltaevent. -
#item ⇒ ResponseOutputItem?
The nested output item on a
response.output_item.addedorresponse.output_item.doneevent, wrapped in a ResponseOutputItem. -
#item_id ⇒ String?
The id of the output item a text delta/done event applies to (
"msg_…"). -
#output_index ⇒ Integer?
The index of the output item this event applies to.
-
#response ⇒ Response?
The nested response object on a
response.createdorresponse.completedevent, wrapped in a Response. -
#sequence_number ⇒ Integer?
The 0-based sequence number of this event within the turn.
-
#text ⇒ String?
The assembled text on a
response.output_text.doneevent. -
#type ⇒ String?
The event type, e.g.
Methods inherited from HermesAgent::Client::Entity
Instance Method Details
#content_index ⇒ Integer?
The index of the content part within the item this event applies to.
371 372 373 |
# File 'lib/hermes_agent/client/entities/response.rb', line 371 def content_index self["content_index"] end |
#delta ⇒ String?
The incremental text on a response.output_text.delta event.
338 339 340 |
# File 'lib/hermes_agent/client/entities/response.rb', line 338 def delta self["delta"] end |
#item ⇒ ResponseOutputItem?
The nested output item on a response.output_item.added or
response.output_item.done event, wrapped in a
HermesAgent::Client::Entities::ResponseOutputItem. Returns nil on events that carry no item.
392 393 394 395 |
# File 'lib/hermes_agent/client/entities/response.rb', line 392 def item raw = self["item"] raw.is_a?(::Hash) ? ResponseOutputItem.new(raw) : nil end |
#item_id ⇒ String?
The id of the output item a text delta/done event applies to
("msg_…").
355 356 357 |
# File 'lib/hermes_agent/client/entities/response.rb', line 355 def item_id self["item_id"] end |
#output_index ⇒ Integer?
The index of the output item this event applies to.
363 364 365 |
# File 'lib/hermes_agent/client/entities/response.rb', line 363 def output_index self["output_index"] end |
#response ⇒ Response?
The nested response object on a response.created or
response.completed event, wrapped in a HermesAgent::Client::Entities::Response. Returns nil on
events that carry no response object.
381 382 383 384 |
# File 'lib/hermes_agent/client/entities/response.rb', line 381 def response raw = self["response"] raw.is_a?(::Hash) ? Response.new(raw) : nil end |
#sequence_number ⇒ Integer?
The 0-based sequence number of this event within the turn.
330 331 332 |
# File 'lib/hermes_agent/client/entities/response.rb', line 330 def sequence_number self["sequence_number"] end |
#text ⇒ String?
The assembled text on a response.output_text.done event.
346 347 348 |
# File 'lib/hermes_agent/client/entities/response.rb', line 346 def text self["text"] end |
#type ⇒ String?
The event type, e.g. "response.output_text.delta" or
"response.completed".
322 323 324 |
# File 'lib/hermes_agent/client/entities/response.rb', line 322 def type self["type"] end |