@agentica/core 0.16.4 → 0.16.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,386 +32,334 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
35
38
  Object.defineProperty(exports, "__esModule", { value: true });
36
39
  exports.ChatGptCompletionMessageUtil = void 0;
37
- const __typia_transform__assertGuard = __importStar(require("typia/lib/internal/_assertGuard.js"));
38
- const typia_1 = require("typia");
40
+ const __typia_transform__validateReport = __importStar(require("typia/lib/internal/_validateReport.js"));
41
+ const typia_1 = __importDefault(require("typia"));
39
42
  const ByteArrayUtil_1 = require("./ByteArrayUtil");
40
43
  const ChatGptTokenUsageAggregator_1 = require("./ChatGptTokenUsageAggregator");
41
44
  function transformCompletionChunk(source) {
42
45
  const str = source instanceof Uint8Array ? ByteArrayUtil_1.ByteArrayUtil.toUtf8(source) : source;
43
- return (() => { const _io0 = input => "string" === typeof input.id && (Array.isArray(input.choices) && input.choices.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && "number" === typeof input.created && "string" === typeof input.model && "chat.completion.chunk" === input.object && (null === input.service_tier || undefined === input.service_tier || "scale" === input.service_tier || "default" === input.service_tier) && (undefined === input.system_fingerprint || "string" === typeof input.system_fingerprint) && (null === input.usage || undefined === input.usage || "object" === typeof input.usage && null !== input.usage && _io9(input.usage)); const _io1 = input => "object" === typeof input.delta && null !== input.delta && false === Array.isArray(input.delta) && _io2(input.delta) && (null === input.finish_reason || "function_call" === input.finish_reason || "stop" === input.finish_reason || "length" === input.finish_reason || "tool_calls" === input.finish_reason || "content_filter" === input.finish_reason) && "number" === typeof input.index && (null === input.logprobs || undefined === input.logprobs || "object" === typeof input.logprobs && null !== input.logprobs && _io6(input.logprobs)); const _io2 = input => (null === input.content || undefined === input.content || "string" === typeof input.content) && (undefined === input.function_call || "object" === typeof input.function_call && null !== input.function_call && false === Array.isArray(input.function_call) && _io3(input.function_call)) && (null === input.refusal || undefined === input.refusal || "string" === typeof input.refusal) && (undefined === input.role || "assistant" === input.role || "user" === input.role || "developer" === input.role || "system" === input.role || "tool" === input.role) && (undefined === input.tool_calls || Array.isArray(input.tool_calls) && input.tool_calls.every(elem => "object" === typeof elem && null !== elem && _io4(elem))); const _io3 = input => (undefined === input.arguments || "string" === typeof input.arguments) && (undefined === input.name || "string" === typeof input.name); const _io4 = input => "number" === typeof input.index && (undefined === input.id || "string" === typeof input.id) && (undefined === input["function"] || "object" === typeof input["function"] && null !== input["function"] && false === Array.isArray(input["function"]) && _io5(input["function"])) && (undefined === input.type || "function" === input.type); const _io5 = input => (undefined === input.arguments || "string" === typeof input.arguments) && (undefined === input.name || "string" === typeof input.name); const _io6 = input => (null === input.content || Array.isArray(input.content) && input.content.every(elem => "object" === typeof elem && null !== elem && _io7(elem))) && (null === input.refusal || Array.isArray(input.refusal) && input.refusal.every(elem => "object" === typeof elem && null !== elem && _io7(elem))); const _io7 = input => "string" === typeof input.token && (null === input.bytes || Array.isArray(input.bytes) && input.bytes.every(elem => "number" === typeof elem)) && "number" === typeof input.logprob && (Array.isArray(input.top_logprobs) && input.top_logprobs.every(elem => "object" === typeof elem && null !== elem && _io8(elem))); const _io8 = input => "string" === typeof input.token && (null === input.bytes || Array.isArray(input.bytes) && input.bytes.every(elem => "number" === typeof elem)) && "number" === typeof input.logprob; const _io9 = input => "number" === typeof input.completion_tokens && "number" === typeof input.prompt_tokens && "number" === typeof input.total_tokens && (undefined === input.completion_tokens_details || "object" === typeof input.completion_tokens_details && null !== input.completion_tokens_details && false === Array.isArray(input.completion_tokens_details) && _io10(input.completion_tokens_details)) && (undefined === input.prompt_tokens_details || "object" === typeof input.prompt_tokens_details && null !== input.prompt_tokens_details && false === Array.isArray(input.prompt_tokens_details) && _io11(input.prompt_tokens_details)); const _io10 = input => (undefined === input.accepted_prediction_tokens || "number" === typeof input.accepted_prediction_tokens) && (undefined === input.audio_tokens || "number" === typeof input.audio_tokens) && (undefined === input.reasoning_tokens || "number" === typeof input.reasoning_tokens) && (undefined === input.rejected_prediction_tokens || "number" === typeof input.rejected_prediction_tokens); const _io11 = input => (undefined === input.audio_tokens || "number" === typeof input.audio_tokens) && (undefined === input.cached_tokens || "number" === typeof input.cached_tokens); const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.id || __typia_transform__assertGuard._assertGuard(_exceptionable, {
44
- method: "json.assertParse",
45
- path: _path + ".id",
46
- expected: "string",
47
- value: input.id
48
- }, _errorFactory)) && ((Array.isArray(input.choices) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
49
- method: "json.assertParse",
50
- path: _path + ".choices",
51
- expected: "Array<ChatCompletionChunk.Choice>",
52
- value: input.choices
53
- }, _errorFactory)) && input.choices.every((elem, _index8) => ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
54
- method: "json.assertParse",
55
- path: _path + ".choices[" + _index8 + "]",
56
- expected: "ChatCompletionChunk.Choice",
57
- value: elem
58
- }, _errorFactory)) && _ao1(elem, _path + ".choices[" + _index8 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
59
- method: "json.assertParse",
60
- path: _path + ".choices[" + _index8 + "]",
61
- expected: "ChatCompletionChunk.Choice",
62
- value: elem
63
- }, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
64
- method: "json.assertParse",
65
- path: _path + ".choices",
66
- expected: "Array<ChatCompletionChunk.Choice>",
67
- value: input.choices
68
- }, _errorFactory)) && ("number" === typeof input.created || __typia_transform__assertGuard._assertGuard(_exceptionable, {
69
- method: "json.assertParse",
70
- path: _path + ".created",
71
- expected: "number",
72
- value: input.created
73
- }, _errorFactory)) && ("string" === typeof input.model || __typia_transform__assertGuard._assertGuard(_exceptionable, {
74
- method: "json.assertParse",
75
- path: _path + ".model",
76
- expected: "string",
77
- value: input.model
78
- }, _errorFactory)) && ("chat.completion.chunk" === input.object || __typia_transform__assertGuard._assertGuard(_exceptionable, {
79
- method: "json.assertParse",
80
- path: _path + ".object",
81
- expected: "\"chat.completion.chunk\"",
82
- value: input.object
83
- }, _errorFactory)) && (null === input.service_tier || undefined === input.service_tier || "scale" === input.service_tier || "default" === input.service_tier || __typia_transform__assertGuard._assertGuard(_exceptionable, {
84
- method: "json.assertParse",
85
- path: _path + ".service_tier",
86
- expected: "(\"default\" | \"scale\" | null | undefined)",
87
- value: input.service_tier
88
- }, _errorFactory)) && (undefined === input.system_fingerprint || "string" === typeof input.system_fingerprint || __typia_transform__assertGuard._assertGuard(_exceptionable, {
89
- method: "json.assertParse",
90
- path: _path + ".system_fingerprint",
91
- expected: "(string | undefined)",
92
- value: input.system_fingerprint
93
- }, _errorFactory)) && (null === input.usage || undefined === input.usage || ("object" === typeof input.usage && null !== input.usage || __typia_transform__assertGuard._assertGuard(_exceptionable, {
94
- method: "json.assertParse",
95
- path: _path + ".usage",
96
- expected: "(CompletionUsage | null | undefined)",
97
- value: input.usage
98
- }, _errorFactory)) && _ao9(input.usage, _path + ".usage", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
99
- method: "json.assertParse",
100
- path: _path + ".usage",
101
- expected: "(CompletionUsage | null | undefined)",
102
- value: input.usage
103
- }, _errorFactory)); const _ao1 = (input, _path, _exceptionable = true) => (("object" === typeof input.delta && null !== input.delta && false === Array.isArray(input.delta) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
104
- method: "json.assertParse",
105
- path: _path + ".delta",
106
- expected: "ChatCompletionChunk.Choice.Delta",
107
- value: input.delta
108
- }, _errorFactory)) && _ao2(input.delta, _path + ".delta", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
109
- method: "json.assertParse",
110
- path: _path + ".delta",
111
- expected: "ChatCompletionChunk.Choice.Delta",
112
- value: input.delta
113
- }, _errorFactory)) && (null === input.finish_reason || "function_call" === input.finish_reason || "stop" === input.finish_reason || "length" === input.finish_reason || "tool_calls" === input.finish_reason || "content_filter" === input.finish_reason || __typia_transform__assertGuard._assertGuard(_exceptionable, {
114
- method: "json.assertParse",
115
- path: _path + ".finish_reason",
116
- expected: "(\"content_filter\" | \"function_call\" | \"length\" | \"stop\" | \"tool_calls\" | null)",
117
- value: input.finish_reason
118
- }, _errorFactory)) && ("number" === typeof input.index || __typia_transform__assertGuard._assertGuard(_exceptionable, {
119
- method: "json.assertParse",
120
- path: _path + ".index",
121
- expected: "number",
122
- value: input.index
123
- }, _errorFactory)) && (null === input.logprobs || undefined === input.logprobs || ("object" === typeof input.logprobs && null !== input.logprobs || __typia_transform__assertGuard._assertGuard(_exceptionable, {
124
- method: "json.assertParse",
125
- path: _path + ".logprobs",
126
- expected: "(ChatCompletionChunk.Choice.Logprobs | null | undefined)",
127
- value: input.logprobs
128
- }, _errorFactory)) && _ao6(input.logprobs, _path + ".logprobs", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
129
- method: "json.assertParse",
130
- path: _path + ".logprobs",
131
- expected: "(ChatCompletionChunk.Choice.Logprobs | null | undefined)",
132
- value: input.logprobs
133
- }, _errorFactory)); const _ao2 = (input, _path, _exceptionable = true) => (null === input.content || undefined === input.content || "string" === typeof input.content || __typia_transform__assertGuard._assertGuard(_exceptionable, {
134
- method: "json.assertParse",
135
- path: _path + ".content",
136
- expected: "(null | string | undefined)",
137
- value: input.content
138
- }, _errorFactory)) && (undefined === input.function_call || ("object" === typeof input.function_call && null !== input.function_call && false === Array.isArray(input.function_call) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
139
- method: "json.assertParse",
140
- path: _path + ".function_call",
141
- expected: "(ChatCompletionChunk.Choice.Delta.FunctionCall | undefined)",
142
- value: input.function_call
143
- }, _errorFactory)) && _ao3(input.function_call, _path + ".function_call", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
144
- method: "json.assertParse",
145
- path: _path + ".function_call",
146
- expected: "(ChatCompletionChunk.Choice.Delta.FunctionCall | undefined)",
147
- value: input.function_call
148
- }, _errorFactory)) && (null === input.refusal || undefined === input.refusal || "string" === typeof input.refusal || __typia_transform__assertGuard._assertGuard(_exceptionable, {
149
- method: "json.assertParse",
150
- path: _path + ".refusal",
151
- expected: "(null | string | undefined)",
152
- value: input.refusal
153
- }, _errorFactory)) && (undefined === input.role || "assistant" === input.role || "user" === input.role || "developer" === input.role || "system" === input.role || "tool" === input.role || __typia_transform__assertGuard._assertGuard(_exceptionable, {
154
- method: "json.assertParse",
155
- path: _path + ".role",
156
- expected: "(\"assistant\" | \"developer\" | \"system\" | \"tool\" | \"user\" | undefined)",
157
- value: input.role
158
- }, _errorFactory)) && (undefined === input.tool_calls || (Array.isArray(input.tool_calls) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
159
- method: "json.assertParse",
160
- path: _path + ".tool_calls",
161
- expected: "(Array<ChatCompletionChunk.Choice.Delta.ToolCall> | undefined)",
162
- value: input.tool_calls
163
- }, _errorFactory)) && input.tool_calls.every((elem, _index9) => ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
164
- method: "json.assertParse",
165
- path: _path + ".tool_calls[" + _index9 + "]",
166
- expected: "ChatCompletionChunk.Choice.Delta.ToolCall",
167
- value: elem
168
- }, _errorFactory)) && _ao4(elem, _path + ".tool_calls[" + _index9 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
169
- method: "json.assertParse",
170
- path: _path + ".tool_calls[" + _index9 + "]",
171
- expected: "ChatCompletionChunk.Choice.Delta.ToolCall",
172
- value: elem
173
- }, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
174
- method: "json.assertParse",
175
- path: _path + ".tool_calls",
176
- expected: "(Array<ChatCompletionChunk.Choice.Delta.ToolCall> | undefined)",
177
- value: input.tool_calls
178
- }, _errorFactory)); const _ao3 = (input, _path, _exceptionable = true) => (undefined === input.arguments || "string" === typeof input.arguments || __typia_transform__assertGuard._assertGuard(_exceptionable, {
179
- method: "json.assertParse",
180
- path: _path + ".arguments",
181
- expected: "(string | undefined)",
182
- value: input.arguments
183
- }, _errorFactory)) && (undefined === input.name || "string" === typeof input.name || __typia_transform__assertGuard._assertGuard(_exceptionable, {
184
- method: "json.assertParse",
185
- path: _path + ".name",
186
- expected: "(string | undefined)",
187
- value: input.name
188
- }, _errorFactory)); const _ao4 = (input, _path, _exceptionable = true) => ("number" === typeof input.index || __typia_transform__assertGuard._assertGuard(_exceptionable, {
189
- method: "json.assertParse",
190
- path: _path + ".index",
191
- expected: "number",
192
- value: input.index
193
- }, _errorFactory)) && (undefined === input.id || "string" === typeof input.id || __typia_transform__assertGuard._assertGuard(_exceptionable, {
194
- method: "json.assertParse",
195
- path: _path + ".id",
196
- expected: "(string | undefined)",
197
- value: input.id
198
- }, _errorFactory)) && (undefined === input["function"] || ("object" === typeof input["function"] && null !== input["function"] && false === Array.isArray(input["function"]) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
199
- method: "json.assertParse",
200
- path: _path + "[\"function\"]",
201
- expected: "(ChatCompletionChunk.Choice.Delta.ToolCall.Function | undefined)",
202
- value: input["function"]
203
- }, _errorFactory)) && _ao5(input["function"], _path + "[\"function\"]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
204
- method: "json.assertParse",
205
- path: _path + "[\"function\"]",
206
- expected: "(ChatCompletionChunk.Choice.Delta.ToolCall.Function | undefined)",
207
- value: input["function"]
208
- }, _errorFactory)) && (undefined === input.type || "function" === input.type || __typia_transform__assertGuard._assertGuard(_exceptionable, {
209
- method: "json.assertParse",
210
- path: _path + ".type",
211
- expected: "(\"function\" | undefined)",
212
- value: input.type
213
- }, _errorFactory)); const _ao5 = (input, _path, _exceptionable = true) => (undefined === input.arguments || "string" === typeof input.arguments || __typia_transform__assertGuard._assertGuard(_exceptionable, {
214
- method: "json.assertParse",
215
- path: _path + ".arguments",
216
- expected: "(string | undefined)",
217
- value: input.arguments
218
- }, _errorFactory)) && (undefined === input.name || "string" === typeof input.name || __typia_transform__assertGuard._assertGuard(_exceptionable, {
219
- method: "json.assertParse",
220
- path: _path + ".name",
221
- expected: "(string | undefined)",
222
- value: input.name
223
- }, _errorFactory)); const _ao6 = (input, _path, _exceptionable = true) => (null === input.content || (Array.isArray(input.content) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
224
- method: "json.assertParse",
225
- path: _path + ".content",
226
- expected: "(Array<ChatCompletionTokenLogprob> | null)",
227
- value: input.content
228
- }, _errorFactory)) && input.content.every((elem, _index10) => ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
229
- method: "json.assertParse",
230
- path: _path + ".content[" + _index10 + "]",
231
- expected: "ChatCompletionTokenLogprob",
232
- value: elem
233
- }, _errorFactory)) && _ao7(elem, _path + ".content[" + _index10 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
234
- method: "json.assertParse",
235
- path: _path + ".content[" + _index10 + "]",
236
- expected: "ChatCompletionTokenLogprob",
237
- value: elem
238
- }, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
239
- method: "json.assertParse",
240
- path: _path + ".content",
241
- expected: "(Array<ChatCompletionTokenLogprob> | null)",
242
- value: input.content
243
- }, _errorFactory)) && (null === input.refusal || (Array.isArray(input.refusal) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
244
- method: "json.assertParse",
245
- path: _path + ".refusal",
246
- expected: "(Array<ChatCompletionTokenLogprob> | null)",
247
- value: input.refusal
248
- }, _errorFactory)) && input.refusal.every((elem, _index11) => ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
249
- method: "json.assertParse",
250
- path: _path + ".refusal[" + _index11 + "]",
251
- expected: "ChatCompletionTokenLogprob",
252
- value: elem
253
- }, _errorFactory)) && _ao7(elem, _path + ".refusal[" + _index11 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
254
- method: "json.assertParse",
255
- path: _path + ".refusal[" + _index11 + "]",
256
- expected: "ChatCompletionTokenLogprob",
257
- value: elem
258
- }, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
259
- method: "json.assertParse",
260
- path: _path + ".refusal",
261
- expected: "(Array<ChatCompletionTokenLogprob> | null)",
262
- value: input.refusal
263
- }, _errorFactory)); const _ao7 = (input, _path, _exceptionable = true) => ("string" === typeof input.token || __typia_transform__assertGuard._assertGuard(_exceptionable, {
264
- method: "json.assertParse",
265
- path: _path + ".token",
266
- expected: "string",
267
- value: input.token
268
- }, _errorFactory)) && (null === input.bytes || (Array.isArray(input.bytes) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
269
- method: "json.assertParse",
270
- path: _path + ".bytes",
271
- expected: "(Array<number> | null)",
272
- value: input.bytes
273
- }, _errorFactory)) && input.bytes.every((elem, _index12) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
274
- method: "json.assertParse",
275
- path: _path + ".bytes[" + _index12 + "]",
276
- expected: "number",
277
- value: elem
278
- }, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
279
- method: "json.assertParse",
280
- path: _path + ".bytes",
281
- expected: "(Array<number> | null)",
282
- value: input.bytes
283
- }, _errorFactory)) && ("number" === typeof input.logprob || __typia_transform__assertGuard._assertGuard(_exceptionable, {
284
- method: "json.assertParse",
285
- path: _path + ".logprob",
286
- expected: "number",
287
- value: input.logprob
288
- }, _errorFactory)) && ((Array.isArray(input.top_logprobs) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
289
- method: "json.assertParse",
290
- path: _path + ".top_logprobs",
291
- expected: "Array<ChatCompletionTokenLogprob.TopLogprob>",
292
- value: input.top_logprobs
293
- }, _errorFactory)) && input.top_logprobs.every((elem, _index13) => ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
294
- method: "json.assertParse",
295
- path: _path + ".top_logprobs[" + _index13 + "]",
296
- expected: "ChatCompletionTokenLogprob.TopLogprob",
297
- value: elem
298
- }, _errorFactory)) && _ao8(elem, _path + ".top_logprobs[" + _index13 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
299
- method: "json.assertParse",
300
- path: _path + ".top_logprobs[" + _index13 + "]",
301
- expected: "ChatCompletionTokenLogprob.TopLogprob",
302
- value: elem
303
- }, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
304
- method: "json.assertParse",
305
- path: _path + ".top_logprobs",
306
- expected: "Array<ChatCompletionTokenLogprob.TopLogprob>",
307
- value: input.top_logprobs
308
- }, _errorFactory)); const _ao8 = (input, _path, _exceptionable = true) => ("string" === typeof input.token || __typia_transform__assertGuard._assertGuard(_exceptionable, {
309
- method: "json.assertParse",
310
- path: _path + ".token",
311
- expected: "string",
312
- value: input.token
313
- }, _errorFactory)) && (null === input.bytes || (Array.isArray(input.bytes) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
314
- method: "json.assertParse",
315
- path: _path + ".bytes",
316
- expected: "(Array<number> | null)",
317
- value: input.bytes
318
- }, _errorFactory)) && input.bytes.every((elem, _index14) => "number" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
319
- method: "json.assertParse",
320
- path: _path + ".bytes[" + _index14 + "]",
321
- expected: "number",
322
- value: elem
323
- }, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
324
- method: "json.assertParse",
325
- path: _path + ".bytes",
326
- expected: "(Array<number> | null)",
327
- value: input.bytes
328
- }, _errorFactory)) && ("number" === typeof input.logprob || __typia_transform__assertGuard._assertGuard(_exceptionable, {
329
- method: "json.assertParse",
330
- path: _path + ".logprob",
331
- expected: "number",
332
- value: input.logprob
333
- }, _errorFactory)); const _ao9 = (input, _path, _exceptionable = true) => ("number" === typeof input.completion_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
334
- method: "json.assertParse",
335
- path: _path + ".completion_tokens",
336
- expected: "number",
337
- value: input.completion_tokens
338
- }, _errorFactory)) && ("number" === typeof input.prompt_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
339
- method: "json.assertParse",
340
- path: _path + ".prompt_tokens",
341
- expected: "number",
342
- value: input.prompt_tokens
343
- }, _errorFactory)) && ("number" === typeof input.total_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
344
- method: "json.assertParse",
345
- path: _path + ".total_tokens",
346
- expected: "number",
347
- value: input.total_tokens
348
- }, _errorFactory)) && (undefined === input.completion_tokens_details || ("object" === typeof input.completion_tokens_details && null !== input.completion_tokens_details && false === Array.isArray(input.completion_tokens_details) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
349
- method: "json.assertParse",
350
- path: _path + ".completion_tokens_details",
351
- expected: "(CompletionUsage.CompletionTokensDetails | undefined)",
352
- value: input.completion_tokens_details
353
- }, _errorFactory)) && _ao10(input.completion_tokens_details, _path + ".completion_tokens_details", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
354
- method: "json.assertParse",
355
- path: _path + ".completion_tokens_details",
356
- expected: "(CompletionUsage.CompletionTokensDetails | undefined)",
357
- value: input.completion_tokens_details
358
- }, _errorFactory)) && (undefined === input.prompt_tokens_details || ("object" === typeof input.prompt_tokens_details && null !== input.prompt_tokens_details && false === Array.isArray(input.prompt_tokens_details) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
359
- method: "json.assertParse",
360
- path: _path + ".prompt_tokens_details",
361
- expected: "(CompletionUsage.PromptTokensDetails | undefined)",
362
- value: input.prompt_tokens_details
363
- }, _errorFactory)) && _ao11(input.prompt_tokens_details, _path + ".prompt_tokens_details", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
364
- method: "json.assertParse",
365
- path: _path + ".prompt_tokens_details",
366
- expected: "(CompletionUsage.PromptTokensDetails | undefined)",
367
- value: input.prompt_tokens_details
368
- }, _errorFactory)); const _ao10 = (input, _path, _exceptionable = true) => (undefined === input.accepted_prediction_tokens || "number" === typeof input.accepted_prediction_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
369
- method: "json.assertParse",
370
- path: _path + ".accepted_prediction_tokens",
371
- expected: "(number | undefined)",
372
- value: input.accepted_prediction_tokens
373
- }, _errorFactory)) && (undefined === input.audio_tokens || "number" === typeof input.audio_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
374
- method: "json.assertParse",
375
- path: _path + ".audio_tokens",
376
- expected: "(number | undefined)",
377
- value: input.audio_tokens
378
- }, _errorFactory)) && (undefined === input.reasoning_tokens || "number" === typeof input.reasoning_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
379
- method: "json.assertParse",
380
- path: _path + ".reasoning_tokens",
381
- expected: "(number | undefined)",
382
- value: input.reasoning_tokens
383
- }, _errorFactory)) && (undefined === input.rejected_prediction_tokens || "number" === typeof input.rejected_prediction_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
384
- method: "json.assertParse",
385
- path: _path + ".rejected_prediction_tokens",
386
- expected: "(number | undefined)",
387
- value: input.rejected_prediction_tokens
388
- }, _errorFactory)); const _ao11 = (input, _path, _exceptionable = true) => (undefined === input.audio_tokens || "number" === typeof input.audio_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
389
- method: "json.assertParse",
390
- path: _path + ".audio_tokens",
391
- expected: "(number | undefined)",
392
- value: input.audio_tokens
393
- }, _errorFactory)) && (undefined === input.cached_tokens || "number" === typeof input.cached_tokens || __typia_transform__assertGuard._assertGuard(_exceptionable, {
394
- method: "json.assertParse",
395
- path: _path + ".cached_tokens",
396
- expected: "(number | undefined)",
397
- value: input.cached_tokens
398
- }, _errorFactory)); const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; const __assert = (input, errorFactory) => {
46
+ const result = JSON.parse(str);
47
+ const valid = (() => { const _io0 = input => "string" === typeof input.id && (Array.isArray(input.choices) && input.choices.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && "number" === typeof input.created && "string" === typeof input.model && "chat.completion.chunk" === input.object && (null === input.service_tier || undefined === input.service_tier || "scale" === input.service_tier || "default" === input.service_tier) && (undefined === input.system_fingerprint || "string" === typeof input.system_fingerprint) && (null === input.usage || undefined === input.usage || "object" === typeof input.usage && null !== input.usage && _io9(input.usage)); const _io1 = input => "object" === typeof input.delta && null !== input.delta && false === Array.isArray(input.delta) && _io2(input.delta) && (null === input.finish_reason || "function_call" === input.finish_reason || "stop" === input.finish_reason || "length" === input.finish_reason || "tool_calls" === input.finish_reason || "content_filter" === input.finish_reason) && "number" === typeof input.index && (null === input.logprobs || undefined === input.logprobs || "object" === typeof input.logprobs && null !== input.logprobs && _io6(input.logprobs)); const _io2 = input => (null === input.content || undefined === input.content || "string" === typeof input.content) && (undefined === input.function_call || "object" === typeof input.function_call && null !== input.function_call && false === Array.isArray(input.function_call) && _io3(input.function_call)) && (null === input.refusal || undefined === input.refusal || "string" === typeof input.refusal) && (undefined === input.role || "assistant" === input.role || "user" === input.role || "developer" === input.role || "system" === input.role || "tool" === input.role) && (undefined === input.tool_calls || Array.isArray(input.tool_calls) && input.tool_calls.every(elem => "object" === typeof elem && null !== elem && _io4(elem))); const _io3 = input => (undefined === input.arguments || "string" === typeof input.arguments) && (undefined === input.name || "string" === typeof input.name); const _io4 = input => "number" === typeof input.index && (undefined === input.id || "string" === typeof input.id) && (undefined === input["function"] || "object" === typeof input["function"] && null !== input["function"] && false === Array.isArray(input["function"]) && _io5(input["function"])) && (undefined === input.type || "function" === input.type); const _io5 = input => (undefined === input.arguments || "string" === typeof input.arguments) && (undefined === input.name || "string" === typeof input.name); const _io6 = input => (null === input.content || Array.isArray(input.content) && input.content.every(elem => "object" === typeof elem && null !== elem && _io7(elem))) && (null === input.refusal || Array.isArray(input.refusal) && input.refusal.every(elem => "object" === typeof elem && null !== elem && _io7(elem))); const _io7 = input => "string" === typeof input.token && (null === input.bytes || Array.isArray(input.bytes) && input.bytes.every(elem => "number" === typeof elem)) && "number" === typeof input.logprob && (Array.isArray(input.top_logprobs) && input.top_logprobs.every(elem => "object" === typeof elem && null !== elem && _io8(elem))); const _io8 = input => "string" === typeof input.token && (null === input.bytes || Array.isArray(input.bytes) && input.bytes.every(elem => "number" === typeof elem)) && "number" === typeof input.logprob; const _io9 = input => "number" === typeof input.completion_tokens && "number" === typeof input.prompt_tokens && "number" === typeof input.total_tokens && (undefined === input.completion_tokens_details || "object" === typeof input.completion_tokens_details && null !== input.completion_tokens_details && false === Array.isArray(input.completion_tokens_details) && _io10(input.completion_tokens_details)) && (undefined === input.prompt_tokens_details || "object" === typeof input.prompt_tokens_details && null !== input.prompt_tokens_details && false === Array.isArray(input.prompt_tokens_details) && _io11(input.prompt_tokens_details)); const _io10 = input => (undefined === input.accepted_prediction_tokens || "number" === typeof input.accepted_prediction_tokens) && (undefined === input.audio_tokens || "number" === typeof input.audio_tokens) && (undefined === input.reasoning_tokens || "number" === typeof input.reasoning_tokens) && (undefined === input.rejected_prediction_tokens || "number" === typeof input.rejected_prediction_tokens); const _io11 = input => (undefined === input.audio_tokens || "number" === typeof input.audio_tokens) && (undefined === input.cached_tokens || "number" === typeof input.cached_tokens); const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.id || _report(_exceptionable, {
48
+ path: _path + ".id",
49
+ expected: "string",
50
+ value: input.id
51
+ }), (Array.isArray(input.choices) || _report(_exceptionable, {
52
+ path: _path + ".choices",
53
+ expected: "Array<ChatCompletionChunk.Choice>",
54
+ value: input.choices
55
+ })) && input.choices.map((elem, _index8) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
56
+ path: _path + ".choices[" + _index8 + "]",
57
+ expected: "ChatCompletionChunk.Choice",
58
+ value: elem
59
+ })) && _vo1(elem, _path + ".choices[" + _index8 + "]", true && _exceptionable) || _report(_exceptionable, {
60
+ path: _path + ".choices[" + _index8 + "]",
61
+ expected: "ChatCompletionChunk.Choice",
62
+ value: elem
63
+ })).every(flag => flag) || _report(_exceptionable, {
64
+ path: _path + ".choices",
65
+ expected: "Array<ChatCompletionChunk.Choice>",
66
+ value: input.choices
67
+ }), "number" === typeof input.created || _report(_exceptionable, {
68
+ path: _path + ".created",
69
+ expected: "number",
70
+ value: input.created
71
+ }), "string" === typeof input.model || _report(_exceptionable, {
72
+ path: _path + ".model",
73
+ expected: "string",
74
+ value: input.model
75
+ }), "chat.completion.chunk" === input.object || _report(_exceptionable, {
76
+ path: _path + ".object",
77
+ expected: "\"chat.completion.chunk\"",
78
+ value: input.object
79
+ }), null === input.service_tier || undefined === input.service_tier || "scale" === input.service_tier || "default" === input.service_tier || _report(_exceptionable, {
80
+ path: _path + ".service_tier",
81
+ expected: "(\"default\" | \"scale\" | null | undefined)",
82
+ value: input.service_tier
83
+ }), undefined === input.system_fingerprint || "string" === typeof input.system_fingerprint || _report(_exceptionable, {
84
+ path: _path + ".system_fingerprint",
85
+ expected: "(string | undefined)",
86
+ value: input.system_fingerprint
87
+ }), null === input.usage || undefined === input.usage || ("object" === typeof input.usage && null !== input.usage || _report(_exceptionable, {
88
+ path: _path + ".usage",
89
+ expected: "(CompletionUsage | null | undefined)",
90
+ value: input.usage
91
+ })) && _vo9(input.usage, _path + ".usage", true && _exceptionable) || _report(_exceptionable, {
92
+ path: _path + ".usage",
93
+ expected: "(CompletionUsage | null | undefined)",
94
+ value: input.usage
95
+ })].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => [("object" === typeof input.delta && null !== input.delta && false === Array.isArray(input.delta) || _report(_exceptionable, {
96
+ path: _path + ".delta",
97
+ expected: "ChatCompletionChunk.Choice.Delta",
98
+ value: input.delta
99
+ })) && _vo2(input.delta, _path + ".delta", true && _exceptionable) || _report(_exceptionable, {
100
+ path: _path + ".delta",
101
+ expected: "ChatCompletionChunk.Choice.Delta",
102
+ value: input.delta
103
+ }), null === input.finish_reason || "function_call" === input.finish_reason || "stop" === input.finish_reason || "length" === input.finish_reason || "tool_calls" === input.finish_reason || "content_filter" === input.finish_reason || _report(_exceptionable, {
104
+ path: _path + ".finish_reason",
105
+ expected: "(\"content_filter\" | \"function_call\" | \"length\" | \"stop\" | \"tool_calls\" | null)",
106
+ value: input.finish_reason
107
+ }), "number" === typeof input.index || _report(_exceptionable, {
108
+ path: _path + ".index",
109
+ expected: "number",
110
+ value: input.index
111
+ }), null === input.logprobs || undefined === input.logprobs || ("object" === typeof input.logprobs && null !== input.logprobs || _report(_exceptionable, {
112
+ path: _path + ".logprobs",
113
+ expected: "(ChatCompletionChunk.Choice.Logprobs | null | undefined)",
114
+ value: input.logprobs
115
+ })) && _vo6(input.logprobs, _path + ".logprobs", true && _exceptionable) || _report(_exceptionable, {
116
+ path: _path + ".logprobs",
117
+ expected: "(ChatCompletionChunk.Choice.Logprobs | null | undefined)",
118
+ value: input.logprobs
119
+ })].every(flag => flag); const _vo2 = (input, _path, _exceptionable = true) => [null === input.content || undefined === input.content || "string" === typeof input.content || _report(_exceptionable, {
120
+ path: _path + ".content",
121
+ expected: "(null | string | undefined)",
122
+ value: input.content
123
+ }), undefined === input.function_call || ("object" === typeof input.function_call && null !== input.function_call && false === Array.isArray(input.function_call) || _report(_exceptionable, {
124
+ path: _path + ".function_call",
125
+ expected: "(ChatCompletionChunk.Choice.Delta.FunctionCall | undefined)",
126
+ value: input.function_call
127
+ })) && _vo3(input.function_call, _path + ".function_call", true && _exceptionable) || _report(_exceptionable, {
128
+ path: _path + ".function_call",
129
+ expected: "(ChatCompletionChunk.Choice.Delta.FunctionCall | undefined)",
130
+ value: input.function_call
131
+ }), null === input.refusal || undefined === input.refusal || "string" === typeof input.refusal || _report(_exceptionable, {
132
+ path: _path + ".refusal",
133
+ expected: "(null | string | undefined)",
134
+ value: input.refusal
135
+ }), undefined === input.role || "assistant" === input.role || "user" === input.role || "developer" === input.role || "system" === input.role || "tool" === input.role || _report(_exceptionable, {
136
+ path: _path + ".role",
137
+ expected: "(\"assistant\" | \"developer\" | \"system\" | \"tool\" | \"user\" | undefined)",
138
+ value: input.role
139
+ }), undefined === input.tool_calls || (Array.isArray(input.tool_calls) || _report(_exceptionable, {
140
+ path: _path + ".tool_calls",
141
+ expected: "(Array<ChatCompletionChunk.Choice.Delta.ToolCall> | undefined)",
142
+ value: input.tool_calls
143
+ })) && input.tool_calls.map((elem, _index9) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
144
+ path: _path + ".tool_calls[" + _index9 + "]",
145
+ expected: "ChatCompletionChunk.Choice.Delta.ToolCall",
146
+ value: elem
147
+ })) && _vo4(elem, _path + ".tool_calls[" + _index9 + "]", true && _exceptionable) || _report(_exceptionable, {
148
+ path: _path + ".tool_calls[" + _index9 + "]",
149
+ expected: "ChatCompletionChunk.Choice.Delta.ToolCall",
150
+ value: elem
151
+ })).every(flag => flag) || _report(_exceptionable, {
152
+ path: _path + ".tool_calls",
153
+ expected: "(Array<ChatCompletionChunk.Choice.Delta.ToolCall> | undefined)",
154
+ value: input.tool_calls
155
+ })].every(flag => flag); const _vo3 = (input, _path, _exceptionable = true) => [undefined === input.arguments || "string" === typeof input.arguments || _report(_exceptionable, {
156
+ path: _path + ".arguments",
157
+ expected: "(string | undefined)",
158
+ value: input.arguments
159
+ }), undefined === input.name || "string" === typeof input.name || _report(_exceptionable, {
160
+ path: _path + ".name",
161
+ expected: "(string | undefined)",
162
+ value: input.name
163
+ })].every(flag => flag); const _vo4 = (input, _path, _exceptionable = true) => ["number" === typeof input.index || _report(_exceptionable, {
164
+ path: _path + ".index",
165
+ expected: "number",
166
+ value: input.index
167
+ }), undefined === input.id || "string" === typeof input.id || _report(_exceptionable, {
168
+ path: _path + ".id",
169
+ expected: "(string | undefined)",
170
+ value: input.id
171
+ }), undefined === input["function"] || ("object" === typeof input["function"] && null !== input["function"] && false === Array.isArray(input["function"]) || _report(_exceptionable, {
172
+ path: _path + "[\"function\"]",
173
+ expected: "(ChatCompletionChunk.Choice.Delta.ToolCall.Function | undefined)",
174
+ value: input["function"]
175
+ })) && _vo5(input["function"], _path + "[\"function\"]", true && _exceptionable) || _report(_exceptionable, {
176
+ path: _path + "[\"function\"]",
177
+ expected: "(ChatCompletionChunk.Choice.Delta.ToolCall.Function | undefined)",
178
+ value: input["function"]
179
+ }), undefined === input.type || "function" === input.type || _report(_exceptionable, {
180
+ path: _path + ".type",
181
+ expected: "(\"function\" | undefined)",
182
+ value: input.type
183
+ })].every(flag => flag); const _vo5 = (input, _path, _exceptionable = true) => [undefined === input.arguments || "string" === typeof input.arguments || _report(_exceptionable, {
184
+ path: _path + ".arguments",
185
+ expected: "(string | undefined)",
186
+ value: input.arguments
187
+ }), undefined === input.name || "string" === typeof input.name || _report(_exceptionable, {
188
+ path: _path + ".name",
189
+ expected: "(string | undefined)",
190
+ value: input.name
191
+ })].every(flag => flag); const _vo6 = (input, _path, _exceptionable = true) => [null === input.content || (Array.isArray(input.content) || _report(_exceptionable, {
192
+ path: _path + ".content",
193
+ expected: "(Array<ChatCompletionTokenLogprob> | null)",
194
+ value: input.content
195
+ })) && input.content.map((elem, _index10) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
196
+ path: _path + ".content[" + _index10 + "]",
197
+ expected: "ChatCompletionTokenLogprob",
198
+ value: elem
199
+ })) && _vo7(elem, _path + ".content[" + _index10 + "]", true && _exceptionable) || _report(_exceptionable, {
200
+ path: _path + ".content[" + _index10 + "]",
201
+ expected: "ChatCompletionTokenLogprob",
202
+ value: elem
203
+ })).every(flag => flag) || _report(_exceptionable, {
204
+ path: _path + ".content",
205
+ expected: "(Array<ChatCompletionTokenLogprob> | null)",
206
+ value: input.content
207
+ }), null === input.refusal || (Array.isArray(input.refusal) || _report(_exceptionable, {
208
+ path: _path + ".refusal",
209
+ expected: "(Array<ChatCompletionTokenLogprob> | null)",
210
+ value: input.refusal
211
+ })) && input.refusal.map((elem, _index11) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
212
+ path: _path + ".refusal[" + _index11 + "]",
213
+ expected: "ChatCompletionTokenLogprob",
214
+ value: elem
215
+ })) && _vo7(elem, _path + ".refusal[" + _index11 + "]", true && _exceptionable) || _report(_exceptionable, {
216
+ path: _path + ".refusal[" + _index11 + "]",
217
+ expected: "ChatCompletionTokenLogprob",
218
+ value: elem
219
+ })).every(flag => flag) || _report(_exceptionable, {
220
+ path: _path + ".refusal",
221
+ expected: "(Array<ChatCompletionTokenLogprob> | null)",
222
+ value: input.refusal
223
+ })].every(flag => flag); const _vo7 = (input, _path, _exceptionable = true) => ["string" === typeof input.token || _report(_exceptionable, {
224
+ path: _path + ".token",
225
+ expected: "string",
226
+ value: input.token
227
+ }), null === input.bytes || (Array.isArray(input.bytes) || _report(_exceptionable, {
228
+ path: _path + ".bytes",
229
+ expected: "(Array<number> | null)",
230
+ value: input.bytes
231
+ })) && input.bytes.map((elem, _index12) => "number" === typeof elem || _report(_exceptionable, {
232
+ path: _path + ".bytes[" + _index12 + "]",
233
+ expected: "number",
234
+ value: elem
235
+ })).every(flag => flag) || _report(_exceptionable, {
236
+ path: _path + ".bytes",
237
+ expected: "(Array<number> | null)",
238
+ value: input.bytes
239
+ }), "number" === typeof input.logprob || _report(_exceptionable, {
240
+ path: _path + ".logprob",
241
+ expected: "number",
242
+ value: input.logprob
243
+ }), (Array.isArray(input.top_logprobs) || _report(_exceptionable, {
244
+ path: _path + ".top_logprobs",
245
+ expected: "Array<ChatCompletionTokenLogprob.TopLogprob>",
246
+ value: input.top_logprobs
247
+ })) && input.top_logprobs.map((elem, _index13) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
248
+ path: _path + ".top_logprobs[" + _index13 + "]",
249
+ expected: "ChatCompletionTokenLogprob.TopLogprob",
250
+ value: elem
251
+ })) && _vo8(elem, _path + ".top_logprobs[" + _index13 + "]", true && _exceptionable) || _report(_exceptionable, {
252
+ path: _path + ".top_logprobs[" + _index13 + "]",
253
+ expected: "ChatCompletionTokenLogprob.TopLogprob",
254
+ value: elem
255
+ })).every(flag => flag) || _report(_exceptionable, {
256
+ path: _path + ".top_logprobs",
257
+ expected: "Array<ChatCompletionTokenLogprob.TopLogprob>",
258
+ value: input.top_logprobs
259
+ })].every(flag => flag); const _vo8 = (input, _path, _exceptionable = true) => ["string" === typeof input.token || _report(_exceptionable, {
260
+ path: _path + ".token",
261
+ expected: "string",
262
+ value: input.token
263
+ }), null === input.bytes || (Array.isArray(input.bytes) || _report(_exceptionable, {
264
+ path: _path + ".bytes",
265
+ expected: "(Array<number> | null)",
266
+ value: input.bytes
267
+ })) && input.bytes.map((elem, _index14) => "number" === typeof elem || _report(_exceptionable, {
268
+ path: _path + ".bytes[" + _index14 + "]",
269
+ expected: "number",
270
+ value: elem
271
+ })).every(flag => flag) || _report(_exceptionable, {
272
+ path: _path + ".bytes",
273
+ expected: "(Array<number> | null)",
274
+ value: input.bytes
275
+ }), "number" === typeof input.logprob || _report(_exceptionable, {
276
+ path: _path + ".logprob",
277
+ expected: "number",
278
+ value: input.logprob
279
+ })].every(flag => flag); const _vo9 = (input, _path, _exceptionable = true) => ["number" === typeof input.completion_tokens || _report(_exceptionable, {
280
+ path: _path + ".completion_tokens",
281
+ expected: "number",
282
+ value: input.completion_tokens
283
+ }), "number" === typeof input.prompt_tokens || _report(_exceptionable, {
284
+ path: _path + ".prompt_tokens",
285
+ expected: "number",
286
+ value: input.prompt_tokens
287
+ }), "number" === typeof input.total_tokens || _report(_exceptionable, {
288
+ path: _path + ".total_tokens",
289
+ expected: "number",
290
+ value: input.total_tokens
291
+ }), undefined === input.completion_tokens_details || ("object" === typeof input.completion_tokens_details && null !== input.completion_tokens_details && false === Array.isArray(input.completion_tokens_details) || _report(_exceptionable, {
292
+ path: _path + ".completion_tokens_details",
293
+ expected: "(CompletionUsage.CompletionTokensDetails | undefined)",
294
+ value: input.completion_tokens_details
295
+ })) && _vo10(input.completion_tokens_details, _path + ".completion_tokens_details", true && _exceptionable) || _report(_exceptionable, {
296
+ path: _path + ".completion_tokens_details",
297
+ expected: "(CompletionUsage.CompletionTokensDetails | undefined)",
298
+ value: input.completion_tokens_details
299
+ }), undefined === input.prompt_tokens_details || ("object" === typeof input.prompt_tokens_details && null !== input.prompt_tokens_details && false === Array.isArray(input.prompt_tokens_details) || _report(_exceptionable, {
300
+ path: _path + ".prompt_tokens_details",
301
+ expected: "(CompletionUsage.PromptTokensDetails | undefined)",
302
+ value: input.prompt_tokens_details
303
+ })) && _vo11(input.prompt_tokens_details, _path + ".prompt_tokens_details", true && _exceptionable) || _report(_exceptionable, {
304
+ path: _path + ".prompt_tokens_details",
305
+ expected: "(CompletionUsage.PromptTokensDetails | undefined)",
306
+ value: input.prompt_tokens_details
307
+ })].every(flag => flag); const _vo10 = (input, _path, _exceptionable = true) => [undefined === input.accepted_prediction_tokens || "number" === typeof input.accepted_prediction_tokens || _report(_exceptionable, {
308
+ path: _path + ".accepted_prediction_tokens",
309
+ expected: "(number | undefined)",
310
+ value: input.accepted_prediction_tokens
311
+ }), undefined === input.audio_tokens || "number" === typeof input.audio_tokens || _report(_exceptionable, {
312
+ path: _path + ".audio_tokens",
313
+ expected: "(number | undefined)",
314
+ value: input.audio_tokens
315
+ }), undefined === input.reasoning_tokens || "number" === typeof input.reasoning_tokens || _report(_exceptionable, {
316
+ path: _path + ".reasoning_tokens",
317
+ expected: "(number | undefined)",
318
+ value: input.reasoning_tokens
319
+ }), undefined === input.rejected_prediction_tokens || "number" === typeof input.rejected_prediction_tokens || _report(_exceptionable, {
320
+ path: _path + ".rejected_prediction_tokens",
321
+ expected: "(number | undefined)",
322
+ value: input.rejected_prediction_tokens
323
+ })].every(flag => flag); const _vo11 = (input, _path, _exceptionable = true) => [undefined === input.audio_tokens || "number" === typeof input.audio_tokens || _report(_exceptionable, {
324
+ path: _path + ".audio_tokens",
325
+ expected: "(number | undefined)",
326
+ value: input.audio_tokens
327
+ }), undefined === input.cached_tokens || "number" === typeof input.cached_tokens || _report(_exceptionable, {
328
+ path: _path + ".cached_tokens",
329
+ expected: "(number | undefined)",
330
+ value: input.cached_tokens
331
+ })].every(flag => flag); const __is = input => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return input => {
399
332
  if (false === __is(input)) {
400
- _errorFactory = errorFactory;
401
- ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || __typia_transform__assertGuard._assertGuard(true, {
402
- method: "json.assertParse",
333
+ errors = [];
334
+ _report = __typia_transform__validateReport._validateReport(errors);
335
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
403
336
  path: _path + "",
404
- expected: "ChatCompletionChunk & { usage: CompletionUsage | null | undefined; }",
337
+ expected: "ChatCompletionChunk",
405
338
  value: input
406
- }, _errorFactory)) && _ao0(input, _path + "", true) || __typia_transform__assertGuard._assertGuard(true, {
407
- method: "json.assertParse",
339
+ })) && _vo0(input, _path + "", true) || _report(true, {
408
340
  path: _path + "",
409
- expected: "ChatCompletionChunk & { usage: CompletionUsage | null | undefined; }",
341
+ expected: "ChatCompletionChunk",
410
342
  value: input
411
- }, _errorFactory))(input, "$input", true);
343
+ }))(input, "$input", true);
344
+ const success = 0 === errors.length;
345
+ return success ? {
346
+ success,
347
+ data: input
348
+ } : {
349
+ success,
350
+ errors,
351
+ data: input
352
+ };
412
353
  }
413
- return input;
414
- }; return (input, errorFactory) => __assert(JSON.parse(input), errorFactory); })()(str);
354
+ return {
355
+ success: true,
356
+ data: input
357
+ };
358
+ }; })()(result);
359
+ if (valid.success === false) {
360
+ console.error("Invalid ChatCompletionChunk", valid.errors);
361
+ }
362
+ return result;
415
363
  }
416
364
  function accumulate(origin, chunk) {
417
365
  const choices = origin.choices;