Class: FetchHive::Generated::SseChunk
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- FetchHive::Generated::SseChunk
- Defined in:
- lib/fetch_hive/generated/models/sse_chunk.rb
Overview
A single event in a Server-Sent Events stream. The ‘type` field is a runtime discriminator. Known values: - `reasoning` — a reasoning / thinking chunk (prompt and agent streams) - `response` — a text chunk (prompt and agent streams) - `tool` — a tool invocation result (agent stream only) - `usage` — final token usage event; signals end of meaningful stream content - `summary` — auto-summarization event emitted before reasoning when a thread history was compressed (agent stream only) - `error` — server-side error during streaming The stream is terminated by `data: [DONE]`, which is handled by the SSE parser and never surfaced as a chunk.
Instance Attribute Summary collapse
-
#context_limit ⇒ Object
Model context window size.
-
#done ⇒ Object
Per-chunk boolean flag on ‘response` and `reasoning` events (agent stream).
-
#error ⇒ Object
Error message.
-
#model ⇒ Object
Model identifier.
-
#observation ⇒ Object
Serialised JSON tool result.
-
#original_token_count ⇒ Object
Token count before summarization.
-
#provider ⇒ Object
LLM provider used for summarization.
-
#request_id ⇒ Object
Unique request identifier.
-
#response ⇒ Object
Text content of the chunk.
-
#stop_reason ⇒ Object
Reason the stream ended.
-
#summary_text ⇒ Object
Compressed summary of the prior conversation.
-
#tool ⇒ Object
Tool name.
-
#tool_id ⇒ Object
Unique tool invocation identifier.
-
#tool_input ⇒ Object
Parsed tool input arguments.
-
#tool_type ⇒ Object
Internal tool type identifier.
-
#type ⇒ Object
Event type discriminator.
-
#usage ⇒ Object
Returns the value of attribute usage.
Class Method Summary collapse
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ SseChunk
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from ApiModelBase
_deserialize, #_to_hash, #to_body, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ SseChunk
Initializes the object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 133 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `FetchHive::Generated::SseChunk` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key acceptable_attribute_map = self.class.acceptable_attribute_map attributes = attributes.each_with_object({}) { |(k, v), h| if (!acceptable_attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `FetchHive::Generated::SseChunk`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'type') self.type = attributes[:'type'] end if attributes.key?(:'response') self.response = attributes[:'response'] end if attributes.key?(:'request_id') self.request_id = attributes[:'request_id'] end if attributes.key?(:'model') self.model = attributes[:'model'] end if attributes.key?(:'done') self.done = attributes[:'done'] end if attributes.key?(:'tool_id') self.tool_id = attributes[:'tool_id'] end if attributes.key?(:'tool') self.tool = attributes[:'tool'] end if attributes.key?(:'tool_type') self.tool_type = attributes[:'tool_type'] end if attributes.key?(:'tool_input') if (value = attributes[:'tool_input']).is_a?(Hash) self.tool_input = value end end if attributes.key?(:'observation') self.observation = attributes[:'observation'] end if attributes.key?(:'stop_reason') self.stop_reason = attributes[:'stop_reason'] end if attributes.key?(:'summary_text') self.summary_text = attributes[:'summary_text'] end if attributes.key?(:'original_token_count') self.original_token_count = attributes[:'original_token_count'] end if attributes.key?(:'context_limit') self.context_limit = attributes[:'context_limit'] end if attributes.key?(:'provider') self.provider = attributes[:'provider'] end if attributes.key?(:'error') self.error = attributes[:'error'] end if attributes.key?(:'usage') self.usage = attributes[:'usage'] end end |
Instance Attribute Details
#context_limit ⇒ Object
Model context window size. Present for ‘summary` events.
59 60 61 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 59 def context_limit @context_limit end |
#done ⇒ Object
Per-chunk boolean flag on ‘response` and `reasoning` events (agent stream). Not a terminal event type — use the `usage` event to detect end of stream.
32 33 34 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 32 def done @done end |
#error ⇒ Object
Error message. Present for ‘error` events.
65 66 67 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 65 def error @error end |
#model ⇒ Object
Model identifier. Present on ‘response` and `reasoning` events (prompt stream).
29 30 31 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 29 def model @model end |
#observation ⇒ Object
Serialised JSON tool result. Present for ‘tool` events.
47 48 49 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 47 def observation @observation end |
#original_token_count ⇒ Object
Token count before summarization. Present for ‘summary` events.
56 57 58 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 56 def original_token_count @original_token_count end |
#provider ⇒ Object
LLM provider used for summarization. Present for ‘summary` events.
62 63 64 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 62 def provider @provider end |
#request_id ⇒ Object
Unique request identifier. Present on most events; always present on ‘usage`.
26 27 28 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 26 def request_id @request_id end |
#response ⇒ Object
Text content of the chunk. Present for ‘reasoning` and `response` event types.
23 24 25 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 23 def response @response end |
#stop_reason ⇒ Object
Reason the stream ended. Present on ‘usage` events (e.g. "completed").
50 51 52 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 50 def stop_reason @stop_reason end |
#summary_text ⇒ Object
Compressed summary of the prior conversation. Present for ‘summary` events.
53 54 55 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 53 def summary_text @summary_text end |
#tool ⇒ Object
Tool name. Present for ‘tool` events (e.g. "google_search").
38 39 40 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 38 def tool @tool end |
#tool_id ⇒ Object
Unique tool invocation identifier. Present for ‘tool` events.
35 36 37 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 35 def tool_id @tool_id end |
#tool_input ⇒ Object
Parsed tool input arguments. Present for ‘tool` events.
44 45 46 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 44 def tool_input @tool_input end |
#tool_type ⇒ Object
Internal tool type identifier. Present for ‘tool` events.
41 42 43 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 41 def tool_type @tool_type end |
#type ⇒ Object
Event type discriminator.
20 21 22 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 20 def type @type end |
#usage ⇒ Object
Returns the value of attribute usage.
67 68 69 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 67 def usage @usage end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
93 94 95 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 93 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
98 99 100 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 98 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 70 def self.attribute_map { :'type' => :'type', :'response' => :'response', :'request_id' => :'request_id', :'model' => :'model', :'done' => :'done', :'tool_id' => :'tool_id', :'tool' => :'tool', :'tool_type' => :'tool_type', :'tool_input' => :'tool_input', :'observation' => :'observation', :'stop_reason' => :'stop_reason', :'summary_text' => :'summary_text', :'original_token_count' => :'original_token_count', :'context_limit' => :'context_limit', :'provider' => :'provider', :'error' => :'error', :'usage' => :'usage' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 272 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
126 127 128 129 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 126 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 103 def self.openapi_types { :'type' => :'String', :'response' => :'String', :'request_id' => :'String', :'model' => :'String', :'done' => :'Boolean', :'tool_id' => :'String', :'tool' => :'String', :'tool_type' => :'String', :'tool_input' => :'Hash<String, Object>', :'observation' => :'String', :'stop_reason' => :'String', :'summary_text' => :'String', :'original_token_count' => :'Integer', :'context_limit' => :'Integer', :'provider' => :'String', :'error' => :'String', :'usage' => :'TokenUsage' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 235 def ==(o) return true if self.equal?(o) self.class == o.class && type == o.type && response == o.response && request_id == o.request_id && model == o.model && done == o.done && tool_id == o.tool_id && tool == o.tool && tool_type == o.tool_type && tool_input == o.tool_input && observation == o.observation && stop_reason == o.stop_reason && summary_text == o.summary_text && original_token_count == o.original_token_count && context_limit == o.context_limit && provider == o.provider && error == o.error && usage == o.usage end |
#eql?(o) ⇒ Boolean
259 260 261 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 259 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
265 266 267 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 265 def hash [type, response, request_id, model, done, tool_id, tool, tool_type, tool_input, observation, stop_reason, summary_text, original_token_count, context_limit, provider, error, usage].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
220 221 222 223 224 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 220 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 294 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
228 229 230 231 |
# File 'lib/fetch_hive/generated/models/sse_chunk.rb', line 228 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' true end |