objectiveai 1.1.12 → 1.2.0

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.
Files changed (5) hide show
  1. package/LICENSE +21 -21
  2. package/dist/index.cjs +3060 -663
  3. package/dist/index.d.ts +37572 -1200
  4. package/dist/index.js +3056 -662
  5. package/package.json +64 -61
package/dist/index.cjs CHANGED
@@ -1,120 +1,1319 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MultichatModel = exports.ScoreModel = exports.MultichatLlm = exports.ScoreLlm = exports.Metadata = exports.Auth = exports.Models = exports.Functions = exports.Conversation = exports.Multichat = exports.Score = exports.Chat = void 0;
6
+ exports.Auth = exports.Function = exports.FunctionSchema = exports.Vector = exports.Chat = exports.Ensemble = exports.EnsembleSchema = exports.EnsembleBaseSchema = exports.EnsembleLlm = exports.EnsembleLlmWithFallbacksAndCountSchema = exports.EnsembleLlmSchema = exports.EnsembleLlmBaseWithFallbacksAndCountSchema = exports.EnsembleLlmBaseSchema = exports.VectorResponsesExpressionSchema = exports.VectorResponsesSchema = exports.VectorResponseExpressionSchema = exports.VectorResponseSchema = exports.ToolsExpressionSchema = exports.ToolsSchema = exports.Tool = exports.ToolExpressionSchema = exports.ToolSchema = exports.MessagesExpressionSchema = exports.MessagesSchema = exports.Message = exports.MessageExpressionSchema = exports.MessageSchema = exports.ObjectiveAIErrorSchema = exports.JsonValueExpressionSchema = exports.JsonValueSchema = exports.ExpressionSchema = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
8
+ // Expressions
9
+ exports.ExpressionSchema = zod_1.default
10
+ .object({
11
+ $jmespath: zod_1.default.string().describe("A JMESPath expression."),
12
+ })
13
+ .describe("An expression which evaluates to a value.");
14
+ exports.JsonValueSchema = zod_1.default
15
+ .lazy(() => zod_1.default.union([
16
+ zod_1.default.null(),
17
+ zod_1.default.boolean(),
18
+ zod_1.default.number(),
19
+ zod_1.default.string(),
20
+ zod_1.default.array(exports.JsonValueSchema),
21
+ zod_1.default.record(zod_1.default.string(), exports.JsonValueSchema),
22
+ ]))
23
+ .describe("A JSON value.");
24
+ exports.JsonValueExpressionSchema = zod_1.default
25
+ .lazy(() => zod_1.default.union([
26
+ zod_1.default.null(),
27
+ zod_1.default.boolean(),
28
+ zod_1.default.number(),
29
+ zod_1.default.string(),
30
+ zod_1.default.array(exports.JsonValueExpressionSchema),
31
+ zod_1.default.record(zod_1.default.string(), exports.JsonValueExpressionSchema),
32
+ exports.ExpressionSchema.describe("An expression which evaluates to a JSON value."),
33
+ ]))
34
+ .describe(exports.JsonValueSchema.description);
35
+ // Errors
36
+ exports.ObjectiveAIErrorSchema = zod_1.default
37
+ .object({
38
+ code: zod_1.default.uint32().describe("The status code of the error."),
39
+ message: zod_1.default.any().describe("The message or details of the error."),
40
+ })
41
+ .describe("An error returned by the ObjectiveAI API.");
42
+ // Messages
43
+ exports.MessageSchema = zod_1.default
44
+ .discriminatedUnion("role", [
45
+ Message.DeveloperSchema,
46
+ Message.SystemSchema,
47
+ Message.UserSchema,
48
+ Message.ToolSchema,
49
+ Message.AssistantSchema,
50
+ ])
51
+ .describe("A message exchanged in a chat conversation.");
52
+ exports.MessageExpressionSchema = zod_1.default
53
+ .union([
54
+ zod_1.default
55
+ .discriminatedUnion("role", [
56
+ Message.DeveloperExpressionSchema,
57
+ Message.SystemExpressionSchema,
58
+ Message.UserExpressionSchema,
59
+ Message.ToolExpressionSchema,
60
+ Message.AssistantExpressionSchema,
61
+ ])
62
+ .describe(exports.MessageSchema.description),
63
+ exports.ExpressionSchema.describe("An expression which evaluates to a message."),
64
+ ])
65
+ .describe(exports.MessageSchema.description);
66
+ var Message;
67
+ (function (Message) {
68
+ Message.SimpleContentPartSchema = zod_1.default
69
+ .object({
70
+ type: zod_1.default.literal("text"),
71
+ text: zod_1.default.string().describe("The text content."),
72
+ })
73
+ .describe("A simple text content part.");
74
+ Message.SimpleContentSchema = zod_1.default
75
+ .union([SimpleContent.TextSchema, SimpleContent.PartsSchema])
76
+ .describe("Simple content.");
77
+ Message.SimpleContentExpressionSchema = zod_1.default
78
+ .union([
79
+ SimpleContent.TextSchema,
80
+ SimpleContent.PartsExpressionSchema,
81
+ exports.ExpressionSchema.describe("An expression which evaluates to simple content."),
82
+ ])
83
+ .describe(Message.SimpleContentSchema.description);
84
+ let SimpleContent;
85
+ (function (SimpleContent) {
86
+ SimpleContent.TextSchema = zod_1.default.string().describe("Plain text content.");
87
+ SimpleContent.PartSchema = zod_1.default
88
+ .object({
89
+ type: zod_1.default.literal("text"),
90
+ text: zod_1.default.string().describe("The text content."),
91
+ })
92
+ .describe("A simple content part.");
93
+ SimpleContent.PartExpressionSchema = zod_1.default
94
+ .union([
95
+ SimpleContent.PartSchema,
96
+ exports.ExpressionSchema.describe("An expression which evaluates to a simple content part."),
97
+ ])
98
+ .describe(SimpleContent.PartSchema.description);
99
+ SimpleContent.PartsSchema = zod_1.default
100
+ .array(SimpleContent.PartSchema)
101
+ .describe("An array of simple content parts.");
102
+ SimpleContent.PartsExpressionSchema = zod_1.default
103
+ .array(SimpleContent.PartExpressionSchema)
104
+ .describe(SimpleContent.PartsSchema.description);
105
+ })(SimpleContent = Message.SimpleContent || (Message.SimpleContent = {}));
106
+ Message.RichContentSchema = zod_1.default
107
+ .union([RichContent.TextSchema, RichContent.PartsSchema])
108
+ .describe("Rich content.");
109
+ Message.RichContentExpressionSchema = zod_1.default
110
+ .union([
111
+ RichContent.TextSchema,
112
+ RichContent.PartsExpressionSchema,
113
+ exports.ExpressionSchema.describe("An expression which evaluates to rich content."),
114
+ ])
115
+ .describe(Message.RichContentSchema.description);
116
+ let RichContent;
117
+ (function (RichContent) {
118
+ RichContent.TextSchema = zod_1.default.string().describe("Plain text content.");
119
+ RichContent.PartSchema = zod_1.default
120
+ .discriminatedUnion("type", [
121
+ Part.TextSchema,
122
+ Part.ImageUrlSchema,
123
+ Part.InputAudioSchema,
124
+ Part.VideoUrlSchema,
125
+ Part.FileSchema,
126
+ ])
127
+ .describe("A rich content part.");
128
+ RichContent.PartExpressionSchema = zod_1.default
129
+ .union([
130
+ RichContent.PartSchema,
131
+ exports.ExpressionSchema.describe("An expression which evaluates to a rich content part."),
132
+ ])
133
+ .describe(RichContent.PartSchema.description);
134
+ let Part;
135
+ (function (Part) {
136
+ Part.TextSchema = zod_1.default
137
+ .object({
138
+ type: zod_1.default.literal("text"),
139
+ text: Text.TextSchema,
140
+ })
141
+ .describe("A text rich content part.");
142
+ let Text;
143
+ (function (Text) {
144
+ Text.TextSchema = zod_1.default.string().describe("The text content.");
145
+ })(Text = Part.Text || (Part.Text = {}));
146
+ Part.ImageUrlSchema = zod_1.default
147
+ .object({
148
+ type: zod_1.default.literal("image_url"),
149
+ image_url: ImageUrl.DefinitionSchema,
150
+ })
151
+ .describe("An image rich content part.");
152
+ let ImageUrl;
153
+ (function (ImageUrl) {
154
+ ImageUrl.DetailSchema = zod_1.default
155
+ .enum(["auto", "low", "high"])
156
+ .describe("Specifies the detail level of the image.");
157
+ ImageUrl.UrlSchema = zod_1.default
158
+ .string()
159
+ .describe("Either a URL of the image or the base64 encoded image data.");
160
+ ImageUrl.DefinitionSchema = zod_1.default
161
+ .object({
162
+ url: ImageUrl.UrlSchema,
163
+ detail: ImageUrl.DetailSchema.optional().nullable(),
164
+ })
165
+ .describe("The URL of the image and its optional detail level.");
166
+ })(ImageUrl = Part.ImageUrl || (Part.ImageUrl = {}));
167
+ Part.InputAudioSchema = zod_1.default
168
+ .object({
169
+ type: zod_1.default.literal("input_audio"),
170
+ input_audio: InputAudio.DefinitionSchema,
171
+ })
172
+ .describe("An audio rich content part.");
173
+ let InputAudio;
174
+ (function (InputAudio) {
175
+ InputAudio.FormatSchema = zod_1.default
176
+ .enum(["wav", "mp3"])
177
+ .describe("The format of the encoded audio data.");
178
+ InputAudio.DataSchema = zod_1.default
179
+ .string()
180
+ .describe("Base64 encoded audio data.");
181
+ InputAudio.DefinitionSchema = zod_1.default
182
+ .object({
183
+ data: InputAudio.DataSchema,
184
+ format: InputAudio.FormatSchema,
185
+ })
186
+ .describe("The audio data and its format.");
187
+ })(InputAudio = Part.InputAudio || (Part.InputAudio = {}));
188
+ Part.VideoUrlSchema = zod_1.default
189
+ .object({
190
+ type: zod_1.default.enum(["video_url", "input_video"]),
191
+ video_url: VideoUrl.DefinitionSchema,
192
+ })
193
+ .describe("A video rich content part.");
194
+ let VideoUrl;
195
+ (function (VideoUrl) {
196
+ VideoUrl.UrlSchema = zod_1.default.string().describe("URL of the video.");
197
+ VideoUrl.DefinitionSchema = zod_1.default.object({
198
+ url: VideoUrl.UrlSchema,
199
+ });
200
+ })(VideoUrl = Part.VideoUrl || (Part.VideoUrl = {}));
201
+ Part.FileSchema = zod_1.default
202
+ .object({
203
+ type: zod_1.default.literal("file"),
204
+ file: File.DefinitionSchema,
205
+ })
206
+ .describe("A file rich content part.");
207
+ let File;
208
+ (function (File) {
209
+ File.FileDataSchema = zod_1.default
210
+ .string()
211
+ .describe("The base64 encoded file data, used when passing the file to the model as a string.");
212
+ File.FileIdSchema = zod_1.default
213
+ .string()
214
+ .describe("The ID of an uploaded file to use as input.");
215
+ File.FilenameSchema = zod_1.default
216
+ .string()
217
+ .describe("The name of the file, used when passing the file to the model as a string.");
218
+ File.FileUrlSchema = zod_1.default
219
+ .string()
220
+ .describe("The URL of the file, used when passing the file to the model as a URL.");
221
+ File.DefinitionSchema = zod_1.default
222
+ .object({
223
+ file_data: File.FileDataSchema.optional().nullable(),
224
+ file_id: File.FileIdSchema.optional().nullable(),
225
+ filename: File.FilenameSchema.optional().nullable(),
226
+ file_url: File.FileUrlSchema.optional().nullable(),
227
+ })
228
+ .describe("The file to be used as input, either as base64 data, an uploaded file ID, or a URL.");
229
+ })(File = Part.File || (Part.File = {}));
230
+ })(Part = RichContent.Part || (RichContent.Part = {}));
231
+ RichContent.PartsSchema = zod_1.default
232
+ .array(RichContent.PartSchema)
233
+ .describe("An array of rich content parts.");
234
+ RichContent.PartsExpressionSchema = zod_1.default
235
+ .array(RichContent.PartExpressionSchema)
236
+ .describe(RichContent.PartsSchema.description);
237
+ })(RichContent = Message.RichContent || (Message.RichContent = {}));
238
+ Message.NameSchema = zod_1.default
239
+ .string()
240
+ .describe("An optional name for the participant. Provides the model information to differentiate between participants of the same role.");
241
+ Message.NameExpressionSchema = zod_1.default
242
+ .union([
243
+ Message.NameSchema,
244
+ exports.ExpressionSchema.describe("An expression which evaluates to a string."),
245
+ ])
246
+ .describe(Message.NameSchema.description);
247
+ Message.DeveloperSchema = zod_1.default
248
+ .object({
249
+ role: zod_1.default.literal("developer"),
250
+ content: Message.SimpleContentSchema,
251
+ name: Message.NameSchema.optional().nullable(),
252
+ })
253
+ .describe("Developer-provided instructions that the model should follow, regardless of messages sent by the user.");
254
+ Message.DeveloperExpressionSchema = zod_1.default
255
+ .object({
256
+ role: zod_1.default.literal("developer"),
257
+ content: Message.SimpleContentExpressionSchema,
258
+ name: Message.NameExpressionSchema.optional().nullable(),
259
+ })
260
+ .describe(Message.DeveloperSchema.description);
261
+ Message.SystemSchema = zod_1.default
262
+ .object({
263
+ role: zod_1.default.literal("system"),
264
+ content: Message.SimpleContentSchema,
265
+ name: Message.NameSchema.optional().nullable(),
266
+ })
267
+ .describe("Developer-provided instructions that the model should follow, regardless of messages sent by the user.");
268
+ Message.SystemExpressionSchema = zod_1.default
269
+ .object({
270
+ role: zod_1.default.literal("system"),
271
+ content: Message.SimpleContentExpressionSchema,
272
+ name: Message.NameExpressionSchema.optional().nullable(),
273
+ })
274
+ .describe(Message.SystemSchema.description);
275
+ Message.UserSchema = zod_1.default
276
+ .object({
277
+ role: zod_1.default.literal("user"),
278
+ content: Message.RichContentSchema,
279
+ name: Message.NameSchema.optional().nullable(),
280
+ })
281
+ .describe("Messages sent by an end user, containing prompts or additional context information.");
282
+ Message.UserExpressionSchema = zod_1.default
283
+ .object({
284
+ role: zod_1.default.literal("user"),
285
+ content: Message.RichContentExpressionSchema,
286
+ name: Message.NameExpressionSchema.optional().nullable(),
287
+ })
288
+ .describe(Message.UserSchema.description);
289
+ Message.ToolSchema = zod_1.default
290
+ .object({
291
+ role: zod_1.default.literal("tool"),
292
+ content: Message.RichContentSchema,
293
+ tool_call_id: Tool.ToolCallIdSchema,
294
+ })
295
+ .describe("Messages sent by tools in response to tool calls made by the assistant.");
296
+ Message.ToolExpressionSchema = zod_1.default
297
+ .object({
298
+ role: zod_1.default.literal("tool"),
299
+ content: Message.RichContentExpressionSchema,
300
+ tool_call_id: Tool.ToolCallIdExpressionSchema,
301
+ })
302
+ .describe(Message.ToolSchema.description);
303
+ let Tool;
304
+ (function (Tool) {
305
+ Tool.ToolCallIdSchema = zod_1.default
306
+ .string()
307
+ .describe("The ID of the tool call that this message is responding to.");
308
+ Tool.ToolCallIdExpressionSchema = zod_1.default
309
+ .union([
310
+ Tool.ToolCallIdSchema,
311
+ exports.ExpressionSchema.describe("An expression which evaluates to a string."),
312
+ ])
313
+ .describe(Tool.ToolCallIdSchema.description);
314
+ })(Tool = Message.Tool || (Message.Tool = {}));
315
+ Message.AssistantSchema = zod_1.default
316
+ .object({
317
+ role: zod_1.default.literal("assistant"),
318
+ content: Message.RichContentSchema.optional().nullable(),
319
+ name: Message.NameSchema.optional().nullable(),
320
+ refusal: Assistant.RefusalSchema.optional().nullable(),
321
+ tool_calls: Assistant.ToolCallsSchema.optional().nullable(),
322
+ reasoning: Assistant.ReasoningSchema.optional().nullable(),
323
+ })
324
+ .describe("Messages sent by the model in response to user messages.");
325
+ Message.AssistantExpressionSchema = zod_1.default
326
+ .object({
327
+ role: zod_1.default.literal("assistant"),
328
+ content: Message.RichContentExpressionSchema.optional().nullable(),
329
+ name: Message.NameExpressionSchema.optional().nullable(),
330
+ refusal: Assistant.RefusalExpressionSchema.optional().nullable(),
331
+ tool_calls: Assistant.ToolCallsExpressionSchema.optional().nullable(),
332
+ reasoning: Assistant.ReasoningExpressionSchema.optional().nullable(),
333
+ })
334
+ .describe(Message.AssistantSchema.description);
335
+ let Assistant;
336
+ (function (Assistant) {
337
+ Assistant.RefusalSchema = zod_1.default
338
+ .string()
339
+ .describe("The refusal message by the assistant.");
340
+ Assistant.RefusalExpressionSchema = zod_1.default
341
+ .union([
342
+ Assistant.RefusalSchema,
343
+ exports.ExpressionSchema.describe("An expression which evaluates to a string."),
344
+ ])
345
+ .describe(Assistant.RefusalSchema.description);
346
+ Assistant.ReasoningSchema = zod_1.default
347
+ .string()
348
+ .describe("The reasoning provided by the assistant.");
349
+ Assistant.ReasoningExpressionSchema = zod_1.default
350
+ .union([
351
+ Assistant.ReasoningSchema,
352
+ exports.ExpressionSchema.describe("An expression which evaluates to a string."),
353
+ ])
354
+ .describe(Assistant.ReasoningSchema.description);
355
+ Assistant.ToolCallSchema = zod_1.default
356
+ .union([ToolCall.FunctionSchema])
357
+ .describe("A tool call made by the assistant.");
358
+ Assistant.ToolCallExpressionSchema = zod_1.default
359
+ .union([
360
+ ToolCall.FunctionExpressionSchema,
361
+ exports.ExpressionSchema.describe("An expression which evaluates to a tool call."),
362
+ ])
363
+ .describe(Assistant.ToolCallSchema.description);
364
+ let ToolCall;
365
+ (function (ToolCall) {
366
+ ToolCall.IdSchema = zod_1.default
367
+ .string()
368
+ .describe("The unique identifier for the tool call.");
369
+ ToolCall.IdExpressionSchema = zod_1.default
370
+ .union([
371
+ ToolCall.IdSchema,
372
+ exports.ExpressionSchema.describe("An expression which evaluates to a string."),
373
+ ])
374
+ .describe(ToolCall.IdSchema.description);
375
+ ToolCall.FunctionSchema = zod_1.default
376
+ .object({
377
+ type: zod_1.default.literal("function"),
378
+ id: ToolCall.IdSchema,
379
+ function: Function.DefinitionSchema,
380
+ })
381
+ .describe("A function tool call made by the assistant.");
382
+ ToolCall.FunctionExpressionSchema = zod_1.default
383
+ .object({
384
+ type: zod_1.default.literal("function"),
385
+ id: ToolCall.IdExpressionSchema,
386
+ function: Function.DefinitionExpressionSchema,
387
+ })
388
+ .describe(ToolCall.FunctionSchema.description);
389
+ let Function;
390
+ (function (Function) {
391
+ Function.NameSchema = zod_1.default
392
+ .string()
393
+ .describe("The name of the function called.");
394
+ Function.NameExpressionSchema = zod_1.default
395
+ .union([
396
+ Function.NameSchema,
397
+ exports.ExpressionSchema.describe("An expression which evaluates to a string."),
398
+ ])
399
+ .describe(Function.NameSchema.description);
400
+ Function.ArgumentsSchema = zod_1.default
401
+ .string()
402
+ .describe("The arguments passed to the function.");
403
+ Function.ArgumentsExpressionSchema = zod_1.default
404
+ .union([
405
+ Function.ArgumentsSchema,
406
+ exports.ExpressionSchema.describe("An expression which evaluates to a string."),
407
+ ])
408
+ .describe(Function.ArgumentsSchema.description);
409
+ Function.DefinitionSchema = zod_1.default
410
+ .object({
411
+ name: Function.NameSchema,
412
+ arguments: Function.ArgumentsSchema,
413
+ })
414
+ .describe("The name and arguments of the function called.");
415
+ Function.DefinitionExpressionSchema = zod_1.default
416
+ .object({
417
+ name: Function.NameExpressionSchema,
418
+ arguments: Function.ArgumentsExpressionSchema,
419
+ })
420
+ .describe(Function.DefinitionSchema.description);
421
+ })(Function = ToolCall.Function || (ToolCall.Function = {}));
422
+ })(ToolCall = Assistant.ToolCall || (Assistant.ToolCall = {}));
423
+ Assistant.ToolCallsSchema = zod_1.default
424
+ .array(Assistant.ToolCallSchema)
425
+ .describe("Tool calls made by the assistant.");
426
+ Assistant.ToolCallsExpressionSchema = zod_1.default
427
+ .union([
428
+ zod_1.default
429
+ .array(Assistant.ToolCallExpressionSchema)
430
+ .describe(Assistant.ToolCallsSchema.description),
431
+ exports.ExpressionSchema.describe("An expression which evaluates to an array of tool calls."),
432
+ ])
433
+ .describe(Assistant.ToolCallsSchema.description);
434
+ })(Assistant = Message.Assistant || (Message.Assistant = {}));
435
+ })(Message || (exports.Message = Message = {}));
436
+ exports.MessagesSchema = zod_1.default
437
+ .array(exports.MessageSchema)
438
+ .describe("A list of messages exchanged in a chat conversation.");
439
+ exports.MessagesExpressionSchema = zod_1.default
440
+ .union([
441
+ zod_1.default.array(exports.MessageExpressionSchema).describe(exports.MessagesSchema.description),
442
+ exports.ExpressionSchema.describe("An expression which evaluates to an array of messages."),
443
+ ])
444
+ .describe(exports.MessagesSchema.description);
445
+ // Tools
446
+ exports.ToolSchema = zod_1.default
447
+ .union([Tool.FunctionSchema])
448
+ .describe("A tool that the assistant can call.");
449
+ exports.ToolExpressionSchema = zod_1.default
450
+ .union([
451
+ Tool.FunctionExpressionSchema,
452
+ exports.ExpressionSchema.describe("An expression which evaluates to a tool."),
453
+ ])
454
+ .describe(exports.ToolSchema.description);
455
+ var Tool;
456
+ (function (Tool) {
457
+ Tool.FunctionSchema = zod_1.default
458
+ .object({
459
+ type: zod_1.default.literal("function"),
460
+ function: Function.DefinitionSchema,
461
+ })
462
+ .describe("A function tool that the assistant can call.");
463
+ Tool.FunctionExpressionSchema = zod_1.default
464
+ .object({
465
+ type: zod_1.default.literal("function"),
466
+ function: Function.DefinitionExpressionSchema,
467
+ })
468
+ .describe(Tool.FunctionSchema.description);
469
+ let Function;
470
+ (function (Function) {
471
+ Function.NameSchema = zod_1.default.string().describe("The name of the function.");
472
+ Function.NameExpressionSchema = zod_1.default
473
+ .union([
474
+ Function.NameSchema,
475
+ exports.ExpressionSchema.describe("An expression which evaluates to a string."),
476
+ ])
477
+ .describe(Function.NameSchema.description);
478
+ Function.DescriptionSchema = zod_1.default
479
+ .string()
480
+ .describe("The description of the function.");
481
+ Function.DescriptionExpressionSchema = zod_1.default
482
+ .union([
483
+ Function.DescriptionSchema,
484
+ exports.ExpressionSchema.describe("An expression which evaluates to a string."),
485
+ ])
486
+ .describe(Function.DescriptionSchema.description);
487
+ Function.ParametersSchema = zod_1.default
488
+ .record(zod_1.default.string(), exports.JsonValueSchema)
489
+ .describe("The JSON schema defining the parameters of the function.");
490
+ Function.ParametersExpressionSchema = zod_1.default
491
+ .union([
492
+ zod_1.default.record(zod_1.default.string(), exports.JsonValueExpressionSchema),
493
+ exports.ExpressionSchema.describe("An expression which evaluates to a JSON schema object."),
494
+ ])
495
+ .describe(Function.ParametersSchema.description);
496
+ Function.StrictSchema = zod_1.default
497
+ .boolean()
498
+ .describe("Whether to enforce strict adherence to the parameter schema.");
499
+ Function.StrictExpressionSchema = zod_1.default
500
+ .union([
501
+ Function.StrictSchema,
502
+ exports.ExpressionSchema.describe("An expression which evaluates to a boolean."),
503
+ ])
504
+ .describe(Function.StrictSchema.description);
505
+ Function.DefinitionSchema = zod_1.default
506
+ .object({
507
+ name: Function.NameSchema,
508
+ description: Function.DescriptionSchema.optional().nullable(),
509
+ parameters: Function.ParametersSchema.optional().nullable(),
510
+ strict: Function.StrictSchema.optional().nullable(),
511
+ })
512
+ .describe("The definition of a function tool.");
513
+ Function.DefinitionExpressionSchema = zod_1.default
514
+ .object({
515
+ name: Function.NameExpressionSchema,
516
+ description: Function.DescriptionExpressionSchema.optional().nullable(),
517
+ parameters: Function.ParametersExpressionSchema.optional().nullable(),
518
+ strict: Function.StrictExpressionSchema.optional().nullable(),
519
+ })
520
+ .describe(Function.DefinitionSchema.description);
521
+ })(Function = Tool.Function || (Tool.Function = {}));
522
+ })(Tool || (exports.Tool = Tool = {}));
523
+ exports.ToolsSchema = zod_1.default
524
+ .array(exports.ToolSchema)
525
+ .describe("A list of tools that the assistant can call.");
526
+ exports.ToolsExpressionSchema = zod_1.default
527
+ .union([
528
+ zod_1.default.array(exports.ToolExpressionSchema).describe(exports.ToolsSchema.description),
529
+ exports.ExpressionSchema.describe("An expression which evaluates to an array of tools."),
530
+ ])
531
+ .describe(exports.ToolsSchema.description);
532
+ // Vector Responses
533
+ exports.VectorResponseSchema = Message.RichContentSchema.describe("A possible assistant response. The LLMs in the Ensemble may vote for this option.");
534
+ exports.VectorResponseExpressionSchema = zod_1.default
535
+ .union([
536
+ exports.VectorResponseSchema,
537
+ exports.ExpressionSchema.describe("An expression which evaluates to a possible assistant response."),
538
+ ])
539
+ .describe(exports.VectorResponseSchema.description);
540
+ exports.VectorResponsesSchema = zod_1.default
541
+ .array(exports.VectorResponseSchema)
542
+ .describe("A list of possible assistant responses which the LLMs in the Ensemble will vote on. The output scores will be of the same length, each corresponding to one response. The winner is the response with the highest score.");
543
+ exports.VectorResponsesExpressionSchema = zod_1.default
544
+ .union([
545
+ zod_1.default
546
+ .array(exports.VectorResponseExpressionSchema)
547
+ .describe(exports.VectorResponsesSchema.description),
548
+ exports.ExpressionSchema.describe("An expression which evaluates to an array of possible assistant responses."),
549
+ ])
550
+ .describe(exports.VectorResponsesSchema.description);
551
+ // Ensemble LLM
552
+ exports.EnsembleLlmBaseSchema = zod_1.default
553
+ .object({
554
+ model: zod_1.default.string().describe("The full ID of the LLM to use."),
555
+ output_mode: EnsembleLlm.OutputModeSchema,
556
+ synthetic_reasoning: zod_1.default
557
+ .boolean()
558
+ .optional()
559
+ .nullable()
560
+ .describe("For Vector Completions only, whether to use synthetic reasoning prior to voting. Works for any LLM, even those that do not have native reasoning capabilities."),
561
+ top_logprobs: zod_1.default
562
+ .int()
563
+ .min(0)
564
+ .max(20)
565
+ .optional()
566
+ .nullable()
567
+ .describe("For Vector Completions only, whether to use logprobs to make the vote probabilistic. This means that the LLM can vote for multiple keys based on their logprobabilities. Allows LLMs to express native uncertainty when voting."),
568
+ prefix_messages: exports.MessagesSchema.optional()
569
+ .nullable()
570
+ .describe(`${exports.MessagesSchema.description} These will be prepended to every prompt sent to this LLM. Useful for setting context or influencing behavior.`),
571
+ suffix_messages: exports.MessagesSchema.optional()
572
+ .nullable()
573
+ .describe(`${exports.MessagesSchema.description} These will be appended to every prompt sent to this LLM. Useful for setting context or influencing behavior.`),
574
+ frequency_penalty: zod_1.default
575
+ .number()
576
+ .min(-2.0)
577
+ .max(2.0)
578
+ .optional()
579
+ .nullable()
580
+ .describe("This setting aims to control the repetition of tokens based on how often they appear in the input. It tries to use less frequently those tokens that appear more in the input, proportional to how frequently they occur. Token penalty scales with the number of occurrences. Negative values will encourage token reuse."),
581
+ logit_bias: zod_1.default
582
+ .record(zod_1.default.string(), zod_1.default.int().min(-100).max(100))
583
+ .optional()
584
+ .nullable()
585
+ .describe("Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."),
586
+ max_completion_tokens: zod_1.default
587
+ .int()
588
+ .min(0)
589
+ .max(2147483647)
590
+ .optional()
591
+ .nullable()
592
+ .describe("An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens."),
593
+ presence_penalty: zod_1.default
594
+ .number()
595
+ .min(-2.0)
596
+ .max(2.0)
597
+ .optional()
598
+ .nullable()
599
+ .describe("This setting aims to control the presence of tokens in the output. It tries to encourage the model to use tokens that are less present in the input, proportional to their presence in the input. Token presence scales with the number of occurrences. Negative values will encourage more diverse token usage."),
600
+ stop: EnsembleLlm.StopSchema.optional().nullable(),
601
+ temperature: zod_1.default
602
+ .number()
603
+ .min(0.0)
604
+ .max(2.0)
605
+ .optional()
606
+ .nullable()
607
+ .describe("This setting influences the variety in the model’s responses. Lower values lead to more predictable and typical responses, while higher values encourage more diverse and less common responses. At 0, the model always gives the same response for a given input."),
608
+ top_p: zod_1.default
609
+ .number()
610
+ .min(0.0)
611
+ .max(1.0)
612
+ .optional()
613
+ .nullable()
614
+ .describe("This setting limits the model’s choices to a percentage of likely tokens: only the top tokens whose probabilities add up to P. A lower value makes the model’s responses more predictable, while the default setting allows for a full range of token choices. Think of it like a dynamic Top-K."),
615
+ max_tokens: zod_1.default
616
+ .int()
617
+ .min(0)
618
+ .max(2147483647)
619
+ .optional()
620
+ .nullable()
621
+ .describe("This sets the upper limit for the number of tokens the model can generate in response. It won’t produce more than this limit. The maximum value is the context length minus the prompt length."),
622
+ min_p: zod_1.default
623
+ .number()
624
+ .min(0.0)
625
+ .max(1.0)
626
+ .optional()
627
+ .nullable()
628
+ .describe("Represents the minimum probability for a token to be considered, relative to the probability of the most likely token. (The value changes depending on the confidence level of the most probable token.) If your Min-P is set to 0.1, that means it will only allow for tokens that are at least 1/10th as probable as the best possible option."),
629
+ provider: EnsembleLlm.ProviderSchema.optional().nullable(),
630
+ reasoning: EnsembleLlm.ReasoningSchema.optional().nullable(),
631
+ repetition_penalty: zod_1.default
632
+ .number()
633
+ .min(0.0)
634
+ .max(2.0)
635
+ .optional()
636
+ .nullable()
637
+ .describe("Helps to reduce the repetition of tokens from the input. A higher value makes the model less likely to repeat tokens, but too high a value can make the output less coherent (often with run-on sentences that lack small words). Token penalty scales based on original token’s probability."),
638
+ top_a: zod_1.default
639
+ .number()
640
+ .min(0.0)
641
+ .max(1.0)
642
+ .optional()
643
+ .nullable()
644
+ .describe("Consider only the top tokens with “sufficiently high” probabilities based on the probability of the most likely token. Think of it like a dynamic Top-P. A lower Top-A value focuses the choices based on the highest probability token but with a narrower scope. A higher Top-A value does not necessarily affect the creativity of the output, but rather refines the filtering process based on the maximum probability."),
645
+ top_k: zod_1.default
646
+ .int()
647
+ .min(0)
648
+ .max(2147483647)
649
+ .optional()
650
+ .nullable()
651
+ .describe("This limits the model’s choice of tokens at each step, making it choose from a smaller set. A value of 1 means the model will always pick the most likely next token, leading to predictable results. By default this setting is disabled, making the model to consider all choices."),
652
+ verbosity: EnsembleLlm.VerbositySchema.optional().nullable(),
653
+ })
654
+ .describe("An LLM to be used within an Ensemble or standalone with Chat Completions.");
655
+ exports.EnsembleLlmBaseWithFallbacksAndCountSchema = exports.EnsembleLlmBaseSchema.extend({
656
+ count: zod_1.default
657
+ .uint32()
658
+ .min(1)
659
+ .optional()
660
+ .nullable()
661
+ .describe("A count greater than one effectively means that there are multiple instances of this LLM in an ensemble."),
662
+ fallbacks: zod_1.default
663
+ .array(exports.EnsembleLlmBaseSchema)
664
+ .optional()
665
+ .nullable()
666
+ .describe("A list of fallback LLMs to use if the primary LLM fails."),
667
+ }).describe("An LLM to be used within an Ensemble, including optional fallbacks and count.");
668
+ exports.EnsembleLlmSchema = exports.EnsembleLlmBaseSchema.extend({
669
+ id: zod_1.default.string().describe("The unique identifier for the Ensemble LLM."),
670
+ }).describe("An LLM to be used within an Ensemble or standalone with Chat Completions, including its unique identifier.");
671
+ exports.EnsembleLlmWithFallbacksAndCountSchema = exports.EnsembleLlmSchema.extend({
672
+ count: exports.EnsembleLlmBaseWithFallbacksAndCountSchema.shape.count,
673
+ fallbacks: zod_1.default
674
+ .array(exports.EnsembleLlmSchema)
675
+ .optional()
676
+ .nullable()
677
+ .describe(exports.EnsembleLlmBaseWithFallbacksAndCountSchema.shape.fallbacks.description),
678
+ }).describe("An LLM to be used within an Ensemble, including its unique identifier, optional fallbacks, and count.");
679
+ var EnsembleLlm;
680
+ (function (EnsembleLlm) {
681
+ EnsembleLlm.OutputModeSchema = zod_1.default
682
+ .enum(["instruction", "json_schema", "tool_call"])
683
+ .describe('For Vector Completions only, specifies the LLM\'s voting output mode. For "instruction", the assistant is instructed to output a key. For "json_schema", the assistant is constrained to output a valid key using a JSON schema. For "tool_call", the assistant is instructed to output a tool call to select the key.');
684
+ EnsembleLlm.StopSchema = zod_1.default
685
+ .union([
686
+ zod_1.default
687
+ .string()
688
+ .describe("Generation will stop when this string is generated."),
689
+ zod_1.default
690
+ .array(zod_1.default.string())
691
+ .describe("Generation will stop when any of these strings are generated."),
692
+ ])
693
+ .describe("The assistant will stop when any of the provided strings are generated.");
694
+ EnsembleLlm.ProviderSchema = zod_1.default
695
+ .object({
696
+ allow_fallbacks: zod_1.default
697
+ .boolean()
698
+ .optional()
699
+ .nullable()
700
+ .describe("Whether to allow fallback providers if the preferred provider is unavailable."),
701
+ require_parameters: zod_1.default
702
+ .boolean()
703
+ .optional()
704
+ .nullable()
705
+ .describe("Whether to require that the provider supports all specified parameters."),
706
+ order: zod_1.default
707
+ .array(zod_1.default.string())
708
+ .optional()
709
+ .nullable()
710
+ .describe("An ordered list of provider names to use when selecting a provider for this model."),
711
+ only: zod_1.default
712
+ .array(zod_1.default.string())
713
+ .optional()
714
+ .nullable()
715
+ .describe("A list of provider names to restrict selection to when selecting a provider for this model."),
716
+ ignore: zod_1.default
717
+ .array(zod_1.default.string())
718
+ .optional()
719
+ .nullable()
720
+ .describe("A list of provider names to ignore when selecting a provider for this model."),
721
+ quantizations: zod_1.default
722
+ .array(Provider.QuantizationSchema)
723
+ .optional()
724
+ .nullable()
725
+ .describe("Specifies the quantizations to allow when selecting providers for this model."),
726
+ })
727
+ .describe("Options for selecting the upstream provider of this model.");
728
+ let Provider;
729
+ (function (Provider) {
730
+ Provider.QuantizationSchema = zod_1.default
731
+ .enum([
732
+ "int4",
733
+ "int8",
734
+ "fp4",
735
+ "fp6",
736
+ "fp8",
737
+ "fp16",
738
+ "bf16",
739
+ "fp32",
740
+ "unknown",
741
+ ])
742
+ .describe("An LLM quantization.");
743
+ })(Provider = EnsembleLlm.Provider || (EnsembleLlm.Provider = {}));
744
+ EnsembleLlm.ReasoningSchema = zod_1.default
745
+ .object({
746
+ enabled: zod_1.default
747
+ .boolean()
748
+ .optional()
749
+ .nullable()
750
+ .describe("Enables or disables reasoning for supported models."),
751
+ max_tokens: zod_1.default
752
+ .int()
753
+ .min(0)
754
+ .max(2147483647)
755
+ .optional()
756
+ .nullable()
757
+ .describe("The maximum number of tokens to use for reasoning in a response."),
758
+ effort: Reasoning.EffortSchema.optional().nullable(),
759
+ summary_verbosity: Reasoning.SummaryVerbositySchema.optional().nullable(),
760
+ })
761
+ .optional()
762
+ .nullable()
763
+ .describe("Options for controlling reasoning behavior of the model.");
764
+ let Reasoning;
765
+ (function (Reasoning) {
766
+ Reasoning.EffortSchema = zod_1.default
767
+ .enum(["none", "minimal", "low", "medium", "high", "xhigh"])
768
+ .describe("Constrains effort on reasoning for supported reasoning models. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.");
769
+ Reasoning.SummaryVerbositySchema = zod_1.default
770
+ .enum(["auto", "concise", "detailed"])
771
+ .describe("Controls the verbosity of the reasoning summary for supported reasoning models.");
772
+ })(Reasoning = EnsembleLlm.Reasoning || (EnsembleLlm.Reasoning = {}));
773
+ EnsembleLlm.VerbositySchema = zod_1.default
774
+ .enum(["low", "medium", "high"])
775
+ .describe("Controls the verbosity and length of the model response. Lower values produce more concise responses, while higher values produce more detailed and comprehensive responses.");
776
+ EnsembleLlm.ListItemSchema = zod_1.default.object({
777
+ id: zod_1.default.string().describe("The unique identifier for the Ensemble LLM."),
778
+ });
779
+ async function list(openai, options) {
780
+ const response = await openai.get("/ensemble_llms", options);
781
+ return response;
782
+ }
783
+ EnsembleLlm.list = list;
784
+ EnsembleLlm.RetrieveItemSchema = exports.EnsembleLlmSchema.extend({
785
+ created: zod_1.default
786
+ .uint32()
787
+ .describe("The Unix timestamp (in seconds) when the Ensemble LLM was created."),
788
+ });
789
+ async function retrieve(openai, id, options) {
790
+ const response = await openai.get(`/ensemble_llms/${id}`, options);
791
+ return response;
792
+ }
793
+ EnsembleLlm.retrieve = retrieve;
794
+ EnsembleLlm.HistoricalUsageSchema = zod_1.default.object({
795
+ requests: zod_1.default
796
+ .uint32()
797
+ .describe("The total number of requests made to this Ensemble LLM."),
798
+ completion_tokens: zod_1.default
799
+ .uint32()
800
+ .describe("The total number of completion tokens generated by this Ensemble LLM."),
801
+ prompt_tokens: zod_1.default
802
+ .uint32()
803
+ .describe("The total number of prompt tokens sent to this Ensemble LLM."),
804
+ total_cost: zod_1.default
805
+ .number()
806
+ .describe("The total cost incurred by using this Ensemble LLM."),
807
+ });
808
+ async function retrieveUsage(openai, id, options) {
809
+ const response = await openai.get(`/ensemble_llms/${id}/usage`, options);
810
+ return response;
811
+ }
812
+ EnsembleLlm.retrieveUsage = retrieveUsage;
813
+ })(EnsembleLlm || (exports.EnsembleLlm = EnsembleLlm = {}));
814
+ // Ensemble
815
+ exports.EnsembleBaseSchema = zod_1.default
816
+ .object({
817
+ llms: zod_1.default
818
+ .array(exports.EnsembleLlmBaseWithFallbacksAndCountSchema)
819
+ .describe("The list of LLMs that make up the ensemble."),
820
+ })
821
+ .describe("An ensemble of LLMs.");
822
+ exports.EnsembleSchema = zod_1.default
823
+ .object({
824
+ id: zod_1.default.string().describe("The unique identifier for the Ensemble."),
825
+ llms: zod_1.default
826
+ .array(exports.EnsembleLlmWithFallbacksAndCountSchema)
827
+ .describe(exports.EnsembleBaseSchema.shape.llms.description),
828
+ })
829
+ .describe("An ensemble of LLMs with a unique identifier.");
830
+ var Ensemble;
831
+ (function (Ensemble) {
832
+ Ensemble.ListItemSchema = zod_1.default.object({
833
+ id: zod_1.default.string().describe("The unique identifier for the Ensemble."),
834
+ });
835
+ async function list(openai, options) {
836
+ const response = await openai.get("/ensembles", options);
837
+ return response;
838
+ }
839
+ Ensemble.list = list;
840
+ Ensemble.RetrieveItemSchema = exports.EnsembleSchema.extend({
841
+ created: zod_1.default
842
+ .uint32()
843
+ .describe("The Unix timestamp (in seconds) when the Ensemble was created."),
844
+ });
845
+ async function retrieve(openai, id, options) {
846
+ const response = await openai.get(`/ensembles/${id}`, options);
847
+ return response;
848
+ }
849
+ Ensemble.retrieve = retrieve;
850
+ Ensemble.HistoricalUsageSchema = zod_1.default.object({
851
+ requests: zod_1.default
852
+ .uint32()
853
+ .describe("The total number of requests made to this Ensemble."),
854
+ completion_tokens: zod_1.default
855
+ .uint32()
856
+ .describe("The total number of completion tokens generated by this Ensemble."),
857
+ prompt_tokens: zod_1.default
858
+ .uint32()
859
+ .describe("The total number of prompt tokens sent to this Ensemble."),
860
+ total_cost: zod_1.default
861
+ .number()
862
+ .describe("The total cost incurred by using this Ensemble."),
863
+ });
864
+ async function retrieveUsage(openai, id, options) {
865
+ const response = await openai.get(`/ensembles/${id}/usage`, options);
866
+ return response;
867
+ }
868
+ Ensemble.retrieveUsage = retrieveUsage;
869
+ })(Ensemble || (exports.Ensemble = Ensemble = {}));
870
+ // Chat Completions
4
871
  var Chat;
5
872
  (function (Chat) {
6
873
  let Completions;
7
874
  (function (Completions) {
875
+ let Request;
876
+ (function (Request) {
877
+ Request.ProviderSchema = zod_1.default
878
+ .object({
879
+ data_collection: Provider.DataCollectionSchema.optional().nullable(),
880
+ zdr: zod_1.default
881
+ .boolean()
882
+ .optional()
883
+ .nullable()
884
+ .describe("Whether to enforce Zero Data Retention (ZDR) policies when selecting providers."),
885
+ sort: Provider.SortSchema.optional().nullable(),
886
+ max_price: Provider.MaxPriceSchema.optional().nullable(),
887
+ preferred_min_throughput: zod_1.default
888
+ .number()
889
+ .optional()
890
+ .nullable()
891
+ .describe("Preferred minimum throughput for the provider."),
892
+ preferred_max_latency: zod_1.default
893
+ .number()
894
+ .optional()
895
+ .nullable()
896
+ .describe("Preferred maximum latency for the provider."),
897
+ min_throughput: zod_1.default
898
+ .number()
899
+ .optional()
900
+ .nullable()
901
+ .describe("Minimum throughput for the provider."),
902
+ max_latency: zod_1.default
903
+ .number()
904
+ .optional()
905
+ .nullable()
906
+ .describe("Maximum latency for the provider."),
907
+ })
908
+ .describe("Options for selecting the upstream provider of this completion.");
909
+ let Provider;
910
+ (function (Provider) {
911
+ Provider.DataCollectionSchema = zod_1.default
912
+ .enum(["allow", "deny"])
913
+ .describe("Specifies whether to allow providers which collect data.");
914
+ Provider.SortSchema = zod_1.default
915
+ .enum(["price", "throughput", "latency"])
916
+ .describe("Specifies the sorting strategy for provider selection.");
917
+ Provider.MaxPriceSchema = zod_1.default.object({
918
+ prompt: zod_1.default
919
+ .number()
920
+ .optional()
921
+ .nullable()
922
+ .describe("Maximum price for prompt tokens."),
923
+ completion: zod_1.default
924
+ .number()
925
+ .optional()
926
+ .nullable()
927
+ .describe("Maximum price for completion tokens."),
928
+ image: zod_1.default
929
+ .number()
930
+ .optional()
931
+ .nullable()
932
+ .describe("Maximum price for image generation."),
933
+ audio: zod_1.default
934
+ .number()
935
+ .optional()
936
+ .nullable()
937
+ .describe("Maximum price for audio generation."),
938
+ request: zod_1.default
939
+ .number()
940
+ .optional()
941
+ .nullable()
942
+ .describe("Maximum price per request."),
943
+ });
944
+ })(Provider = Request.Provider || (Request.Provider = {}));
945
+ Request.ModelSchema = zod_1.default
946
+ .union([zod_1.default.string(), exports.EnsembleLlmBaseSchema])
947
+ .describe("The Ensemble LLM to use for this completion. May be a unique ID or an inline definition.");
948
+ Request.ResponseFormatSchema = zod_1.default
949
+ .union([
950
+ ResponseFormat.TextSchema,
951
+ ResponseFormat.JsonObjectSchema,
952
+ ResponseFormat.JsonSchemaSchema,
953
+ ResponseFormat.GrammarSchema,
954
+ ResponseFormat.PythonSchema,
955
+ ])
956
+ .describe("The desired format of the model's response.");
957
+ let ResponseFormat;
958
+ (function (ResponseFormat) {
959
+ ResponseFormat.TextSchema = zod_1.default
960
+ .object({
961
+ type: zod_1.default.literal("text"),
962
+ })
963
+ .describe("The response will be arbitrary text.");
964
+ ResponseFormat.JsonObjectSchema = zod_1.default
965
+ .object({
966
+ type: zod_1.default.literal("json_object"),
967
+ })
968
+ .describe("The response will be a JSON object.");
969
+ ResponseFormat.JsonSchemaSchema = zod_1.default
970
+ .object({
971
+ type: zod_1.default.literal("json_schema"),
972
+ json_schema: JsonSchema.JsonSchemaSchema,
973
+ })
974
+ .describe("The response will conform to the provided JSON schema.");
975
+ let JsonSchema;
976
+ (function (JsonSchema) {
977
+ JsonSchema.JsonSchemaSchema = zod_1.default
978
+ .object({
979
+ name: zod_1.default.string().describe("The name of the JSON schema."),
980
+ description: zod_1.default
981
+ .string()
982
+ .optional()
983
+ .nullable()
984
+ .describe("The description of the JSON schema."),
985
+ schema: zod_1.default
986
+ .any()
987
+ .optional()
988
+ .describe("The JSON schema definition."),
989
+ strict: zod_1.default
990
+ .boolean()
991
+ .optional()
992
+ .nullable()
993
+ .describe("Whether to enforce strict adherence to the JSON schema."),
994
+ })
995
+ .describe("A JSON schema definition for constraining model output.");
996
+ })(JsonSchema = ResponseFormat.JsonSchema || (ResponseFormat.JsonSchema = {}));
997
+ ResponseFormat.GrammarSchema = zod_1.default
998
+ .object({
999
+ type: zod_1.default.literal("grammar"),
1000
+ grammar: zod_1.default
1001
+ .string()
1002
+ .describe("The grammar definition to constrain the response."),
1003
+ })
1004
+ .describe("The response will conform to the provided grammar definition.");
1005
+ ResponseFormat.PythonSchema = zod_1.default
1006
+ .object({
1007
+ type: zod_1.default.literal("python"),
1008
+ })
1009
+ .describe("The response will be Python code.");
1010
+ })(ResponseFormat = Request.ResponseFormat || (Request.ResponseFormat = {}));
1011
+ Request.ToolChoiceSchema = zod_1.default
1012
+ .union([
1013
+ zod_1.default.literal("none"),
1014
+ zod_1.default.literal("auto"),
1015
+ zod_1.default.literal("required"),
1016
+ ToolChoice.FunctionSchema,
1017
+ ])
1018
+ .describe("Specifies tool call behavior for the assistant.");
1019
+ let ToolChoice;
1020
+ (function (ToolChoice) {
1021
+ ToolChoice.FunctionSchema = zod_1.default
1022
+ .object({
1023
+ type: zod_1.default.literal("function"),
1024
+ function: Function.FunctionSchema,
1025
+ })
1026
+ .describe("Specify a function for the assistant to call.");
1027
+ let Function;
1028
+ (function (Function) {
1029
+ Function.FunctionSchema = zod_1.default.object({
1030
+ name: zod_1.default
1031
+ .string()
1032
+ .describe("The name of the function the assistant will call."),
1033
+ });
1034
+ })(Function = ToolChoice.Function || (ToolChoice.Function = {}));
1035
+ })(ToolChoice = Request.ToolChoice || (Request.ToolChoice = {}));
1036
+ Request.PredictionSchema = zod_1.default
1037
+ .object({
1038
+ type: zod_1.default.literal("content"),
1039
+ content: Prediction.ContentSchema,
1040
+ })
1041
+ .describe("Configuration for a Predicted Output, which can greatly improve response times when large parts of the model response are known ahead of time. This is most common when you are regenerating a file with only minor changes to most of the content.");
1042
+ let Prediction;
1043
+ (function (Prediction) {
1044
+ Prediction.ContentSchema = zod_1.default.union([
1045
+ zod_1.default.string(),
1046
+ zod_1.default.array(Content.PartSchema),
1047
+ ]);
1048
+ let Content;
1049
+ (function (Content) {
1050
+ Content.PartSchema = zod_1.default
1051
+ .object({
1052
+ type: zod_1.default.literal("text"),
1053
+ text: zod_1.default.string(),
1054
+ })
1055
+ .describe("A part of the predicted content.");
1056
+ })(Content = Prediction.Content || (Prediction.Content = {}));
1057
+ })(Prediction = Request.Prediction || (Request.Prediction = {}));
1058
+ Request.SeedSchema = zod_1.default
1059
+ .bigint()
1060
+ .describe("If specified, upstream systems will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.");
1061
+ Request.BackoffMaxElapsedTimeSchema = zod_1.default
1062
+ .uint32()
1063
+ .describe("The maximum total time in milliseconds to spend on retries when a transient error occurs.");
1064
+ Request.FirstChunkTimeoutSchema = zod_1.default
1065
+ .uint32()
1066
+ .describe("The maximum time in milliseconds to wait for the first chunk of a streaming response.");
1067
+ Request.OtherChunkTimeoutSchema = zod_1.default
1068
+ .uint32()
1069
+ .describe("The maximum time in milliseconds to wait between subsequent chunks of a streaming response.");
1070
+ Request.ChatCompletionCreateParamsBaseSchema = zod_1.default
1071
+ .object({
1072
+ messages: exports.MessagesSchema,
1073
+ provider: Request.ProviderSchema.optional().nullable(),
1074
+ model: Request.ModelSchema,
1075
+ models: zod_1.default
1076
+ .array(Request.ModelSchema)
1077
+ .optional()
1078
+ .nullable()
1079
+ .describe("Fallback Ensemble LLMs to use if the primary Ensemble LLM fails."),
1080
+ top_logprobs: zod_1.default
1081
+ .int()
1082
+ .min(0)
1083
+ .max(20)
1084
+ .optional()
1085
+ .nullable()
1086
+ .describe("An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability."),
1087
+ response_format: Request.ResponseFormatSchema.optional().nullable(),
1088
+ seed: Request.SeedSchema.optional().nullable(),
1089
+ tool_choice: Request.ToolChoiceSchema.optional().nullable(),
1090
+ tools: exports.ToolsSchema,
1091
+ parallel_tool_calls: zod_1.default
1092
+ .boolean()
1093
+ .optional()
1094
+ .nullable()
1095
+ .describe("Whether to allow the model to make multiple tool calls in parallel."),
1096
+ prediction: Request.PredictionSchema.optional().nullable(),
1097
+ backoff_max_elapsed_time: Request.BackoffMaxElapsedTimeSchema.optional().nullable(),
1098
+ first_chunk_timeout: Request.FirstChunkTimeoutSchema.optional().nullable(),
1099
+ other_chunk_timeout: Request.OtherChunkTimeoutSchema.optional().nullable(),
1100
+ })
1101
+ .describe("Base parameters for creating a chat completion.");
1102
+ Request.StreamTrueSchema = zod_1.default
1103
+ .literal(true)
1104
+ .describe("Whether to stream the response as a series of chunks.");
1105
+ Request.ChatCompletionCreateParamsStreamingSchema = Request.ChatCompletionCreateParamsBaseSchema.extend({
1106
+ stream: Request.StreamTrueSchema,
1107
+ }).describe("Parameters for creating a streaming chat completion.");
1108
+ Request.StreamFalseSchema = zod_1.default
1109
+ .literal(false)
1110
+ .describe("Whether to stream the response as a series of chunks.");
1111
+ Request.ChatCompletionCreateParamsNonStreamingSchema = Request.ChatCompletionCreateParamsBaseSchema.extend({
1112
+ stream: Request.StreamFalseSchema.optional().nullable(),
1113
+ }).describe("Parameters for creating a unary chat completion.");
1114
+ Request.ChatCompletionCreateParamsSchema = zod_1.default
1115
+ .union([
1116
+ Request.ChatCompletionCreateParamsStreamingSchema,
1117
+ Request.ChatCompletionCreateParamsNonStreamingSchema,
1118
+ ])
1119
+ .describe("Parameters for creating a chat completion.");
1120
+ })(Request = Completions.Request || (Completions.Request = {}));
8
1121
  let Response;
9
1122
  (function (Response) {
10
- let Streaming;
11
- (function (Streaming) {
12
- let ChatCompletionChunk;
13
- (function (ChatCompletionChunk) {
14
- function merged(a, b) {
15
- const id = a.id;
16
- const [choices, choicesChanged] = Choice.mergedList(a.choices, b.choices);
17
- const created = a.created;
18
- const model = a.model;
19
- const object = a.object;
20
- const [service_tier, service_tierChanged] = merge(a.service_tier, b.service_tier);
21
- const [system_fingerprint, system_fingerprintChanged] = merge(a.system_fingerprint, b.system_fingerprint);
22
- const [usage, usageChanged] = merge(a.usage, b.usage, Usage.merged);
23
- const [provider, providerChanged] = merge(a.provider, b.provider);
24
- if (choicesChanged ||
25
- service_tierChanged ||
26
- system_fingerprintChanged ||
27
- usageChanged ||
28
- providerChanged) {
29
- return [
30
- Object.assign(Object.assign(Object.assign(Object.assign({ id,
31
- choices,
32
- created,
33
- model,
34
- object }, (service_tier !== undefined ? { service_tier } : {})), (system_fingerprint !== undefined
35
- ? { system_fingerprint }
36
- : {})), (usage !== undefined ? { usage } : {})), (provider !== undefined ? { provider } : {})),
37
- true,
38
- ];
39
- }
40
- else {
41
- return [a, false];
42
- }
1123
+ Response.FinishReasonSchema = zod_1.default
1124
+ .enum(["stop", "length", "tool_calls", "content_filter", "error"])
1125
+ .describe("The reason why the assistant ceased to generate further tokens.");
1126
+ Response.UsageSchema = zod_1.default
1127
+ .object({
1128
+ completion_tokens: zod_1.default
1129
+ .uint32()
1130
+ .describe("The number of tokens generated in the completion."),
1131
+ prompt_tokens: zod_1.default
1132
+ .uint32()
1133
+ .describe("The number of tokens in the prompt."),
1134
+ total_tokens: zod_1.default
1135
+ .uint32()
1136
+ .describe("The total number of tokens used in the prompt or generated in the completion."),
1137
+ completion_tokens_details: Usage.CompletionTokensDetailsSchema.optional(),
1138
+ prompt_tokens_details: Usage.PromptTokensDetailsSchema.optional(),
1139
+ cost: zod_1.default
1140
+ .number()
1141
+ .describe("The cost in credits incurred for this completion."),
1142
+ cost_details: Usage.CostDetailsSchema.optional(),
1143
+ total_cost: zod_1.default
1144
+ .number()
1145
+ .describe("The total cost in credits incurred including upstream costs."),
1146
+ cost_multiplier: zod_1.default
1147
+ .number()
1148
+ .describe("The cost multiplier applied to upstream costs for computing ObjectiveAI costs."),
1149
+ is_byok: zod_1.default
1150
+ .boolean()
1151
+ .describe("Whether the completion used a BYOK (Bring Your Own Key) API Key."),
1152
+ })
1153
+ .describe("Token and cost usage statistics for the completion.");
1154
+ let Usage;
1155
+ (function (Usage) {
1156
+ Usage.CompletionTokensDetailsSchema = zod_1.default
1157
+ .object({
1158
+ accepted_prediction_tokens: zod_1.default
1159
+ .uint32()
1160
+ .optional()
1161
+ .describe("The number of accepted prediction tokens in the completion."),
1162
+ audio_tokens: zod_1.default
1163
+ .uint32()
1164
+ .optional()
1165
+ .describe("The number of generated audio tokens in the completion."),
1166
+ reasoning_tokens: zod_1.default
1167
+ .uint32()
1168
+ .optional()
1169
+ .describe("The number of generated reasoning tokens in the completion."),
1170
+ rejected_prediction_tokens: zod_1.default
1171
+ .uint32()
1172
+ .optional()
1173
+ .describe("The number of rejected prediction tokens in the completion."),
1174
+ })
1175
+ .describe("Detailed breakdown of generated completion tokens.");
1176
+ Usage.PromptTokensDetailsSchema = zod_1.default
1177
+ .object({
1178
+ audio_tokens: zod_1.default
1179
+ .uint32()
1180
+ .optional()
1181
+ .describe("The number of audio tokens in the prompt."),
1182
+ cached_tokens: zod_1.default
1183
+ .uint32()
1184
+ .optional()
1185
+ .describe("The number of cached tokens in the prompt."),
1186
+ cache_write_tokens: zod_1.default
1187
+ .uint32()
1188
+ .optional()
1189
+ .describe("The number of prompt tokens written to cache."),
1190
+ video_tokens: zod_1.default
1191
+ .uint32()
1192
+ .optional()
1193
+ .describe("The number of video tokens in the prompt."),
1194
+ })
1195
+ .describe("Detailed breakdown of prompt tokens.");
1196
+ Usage.CostDetailsSchema = zod_1.default
1197
+ .object({
1198
+ upstream_inference_cost: zod_1.default
1199
+ .number()
1200
+ .optional()
1201
+ .describe("The cost incurred upstream."),
1202
+ upstream_upstream_inference_cost: zod_1.default
1203
+ .number()
1204
+ .optional()
1205
+ .describe("The cost incurred by upstream's upstream."),
1206
+ })
1207
+ .describe("Detailed breakdown of upstream costs incurred.");
1208
+ })(Usage = Response.Usage || (Response.Usage = {}));
1209
+ Response.LogprobsSchema = zod_1.default
1210
+ .object({
1211
+ content: zod_1.default
1212
+ .array(Logprobs.LogprobSchema)
1213
+ .optional()
1214
+ .nullable()
1215
+ .describe("The log probabilities of the tokens in the content."),
1216
+ refusal: zod_1.default
1217
+ .array(Logprobs.LogprobSchema)
1218
+ .optional()
1219
+ .nullable()
1220
+ .describe("The log probabilities of the tokens in the refusal."),
1221
+ })
1222
+ .describe("The log probabilities of the tokens generated by the model.");
1223
+ let Logprobs;
1224
+ (function (Logprobs) {
1225
+ function merged(a, b) {
1226
+ const [content, contentChanged] = merge(a.content, b.content, Logprob.mergedList);
1227
+ const [refusal, refusalChanged] = merge(a.refusal, b.refusal, Logprob.mergedList);
1228
+ if (contentChanged || refusalChanged) {
1229
+ return [{ content, refusal }, true];
43
1230
  }
44
- ChatCompletionChunk.merged = merged;
45
- })(ChatCompletionChunk = Streaming.ChatCompletionChunk || (Streaming.ChatCompletionChunk = {}));
46
- let Choice;
47
- (function (Choice) {
48
- function merged(a, b) {
49
- const [delta, deltaChanged] = merge(a.delta, b.delta, Delta.merged);
50
- const [finish_reason, finish_reasonChanged] = merge(a.finish_reason, b.finish_reason);
51
- const index = a.index;
52
- const [logprobs, logprobsChanged] = merge(a.logprobs, b.logprobs, Logprobs.merged);
53
- if (deltaChanged || finish_reasonChanged || logprobsChanged) {
54
- return [
55
- Object.assign({ delta,
56
- finish_reason,
57
- index }, (logprobs !== undefined ? { logprobs } : {})),
58
- true,
59
- ];
60
- }
61
- else {
62
- return [a, false];
63
- }
1231
+ else {
1232
+ return [a, false];
64
1233
  }
65
- Choice.merged = merged;
1234
+ }
1235
+ Logprobs.merged = merged;
1236
+ Logprobs.LogprobSchema = zod_1.default
1237
+ .object({
1238
+ token: zod_1.default
1239
+ .string()
1240
+ .describe("The token string which was selected by the sampler."),
1241
+ bytes: zod_1.default
1242
+ .array(zod_1.default.uint32())
1243
+ .optional()
1244
+ .nullable()
1245
+ .describe("The byte representation of the token which was selected by the sampler."),
1246
+ logprob: zod_1.default
1247
+ .number()
1248
+ .describe("The log probability of the token which was selected by the sampler."),
1249
+ top_logprobs: zod_1.default
1250
+ .array(Logprob.TopLogprobSchema)
1251
+ .describe("The log probabilities of the top tokens for this position."),
1252
+ })
1253
+ .describe("The token which was selected by the sampler for this position as well as the logprobabilities of the top options.");
1254
+ let Logprob;
1255
+ (function (Logprob) {
66
1256
  function mergedList(a, b) {
67
- let merged = undefined;
68
- for (const choice of b) {
69
- const existingIndex = a.findIndex(({ index }) => index === choice.index);
70
- if (existingIndex === -1) {
71
- if (merged === undefined) {
72
- merged = [...a, choice];
73
- }
74
- else {
75
- merged.push(choice);
76
- }
77
- }
78
- else {
79
- const [mergedChoice, choiceChanged] = Choice.merged(a[existingIndex], choice);
80
- if (choiceChanged) {
81
- if (merged === undefined) {
82
- merged = [...a];
83
- }
84
- merged[existingIndex] = mergedChoice;
85
- }
86
- }
1257
+ if (b.length === 0) {
1258
+ return [a, false];
87
1259
  }
88
- return merged ? [merged, true] : [a, false];
89
- }
90
- Choice.mergedList = mergedList;
91
- })(Choice = Streaming.Choice || (Streaming.Choice = {}));
92
- let Delta;
93
- (function (Delta) {
94
- function merged(a, b) {
95
- const [content, contentChanged] = merge(a.content, b.content, mergedString);
96
- const [refusal, refusalChanged] = merge(a.refusal, b.refusal, mergedString);
97
- const [role, roleChanged] = merge(a.role, b.role);
98
- const [tool_calls, tool_callsChanged] = merge(a.tool_calls, b.tool_calls, ToolCall.mergedList);
99
- const [reasoning, reasoningChanged] = merge(a.reasoning, b.reasoning, mergedString);
100
- const [images, imagesChanged] = merge(a.images, b.images, Image.mergedList);
101
- if (contentChanged ||
102
- reasoningChanged ||
103
- refusalChanged ||
104
- roleChanged ||
105
- tool_callsChanged ||
106
- imagesChanged) {
107
- return [
108
- Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (content !== undefined ? { content } : {})), (reasoning !== undefined ? { reasoning } : {})), (refusal !== undefined ? { refusal } : {})), (role !== undefined ? { role } : {})), (tool_calls !== undefined ? { tool_calls } : {})), (images !== undefined ? { images } : {})),
109
- true,
110
- ];
1260
+ else if (a.length === 0) {
1261
+ return [b, true];
111
1262
  }
112
1263
  else {
113
- return [a, false];
1264
+ return [[...a, ...b], true];
114
1265
  }
115
1266
  }
116
- Delta.merged = merged;
117
- })(Delta = Streaming.Delta || (Streaming.Delta = {}));
1267
+ Logprob.mergedList = mergedList;
1268
+ Logprob.TopLogprobSchema = zod_1.default
1269
+ .object({
1270
+ token: zod_1.default.string().describe("The token string."),
1271
+ bytes: zod_1.default
1272
+ .array(zod_1.default.uint32())
1273
+ .optional()
1274
+ .nullable()
1275
+ .describe("The byte representation of the token."),
1276
+ logprob: zod_1.default
1277
+ .number()
1278
+ .optional()
1279
+ .nullable()
1280
+ .describe("The log probability of the token."),
1281
+ })
1282
+ .describe("The log probability of a token in the list of top tokens.");
1283
+ })(Logprob = Logprobs.Logprob || (Logprobs.Logprob = {}));
1284
+ })(Logprobs = Response.Logprobs || (Response.Logprobs = {}));
1285
+ Response.RoleSchema = zod_1.default
1286
+ .enum(["assistant"])
1287
+ .describe("The role of the message author.");
1288
+ Response.ImageSchema = zod_1.default
1289
+ .union([Image.ImageUrlSchema])
1290
+ .describe("An image generated by the model.");
1291
+ let Image;
1292
+ (function (Image) {
1293
+ function mergedList(a, b) {
1294
+ if (b.length === 0) {
1295
+ return [a, false];
1296
+ }
1297
+ else if (a.length === 0) {
1298
+ return [b, true];
1299
+ }
1300
+ else {
1301
+ return [[...a, ...b], true];
1302
+ }
1303
+ }
1304
+ Image.mergedList = mergedList;
1305
+ Image.ImageUrlSchema = zod_1.default.object({
1306
+ type: zod_1.default.literal("image_url"),
1307
+ image_url: zod_1.default.object({
1308
+ url: zod_1.default.string().describe("The Base64 URL of the generated image."),
1309
+ }),
1310
+ });
1311
+ })(Image = Response.Image || (Response.Image = {}));
1312
+ let Streaming;
1313
+ (function (Streaming) {
1314
+ Streaming.ToolCallSchema = zod_1.default
1315
+ .union([ToolCall.FunctionSchema])
1316
+ .describe("A tool call made by the assistant.");
118
1317
  let ToolCall;
119
1318
  (function (ToolCall) {
120
1319
  function merged(a, b) {
@@ -146,13 +1345,26 @@ var Chat;
146
1345
  return merged ? [merged, true] : [a, false];
147
1346
  }
148
1347
  ToolCall.mergedList = mergedList;
1348
+ ToolCall.FunctionSchema = zod_1.default
1349
+ .object({
1350
+ index: zod_1.default
1351
+ .uint32()
1352
+ .describe("The index of the tool call in the sequence of tool calls."),
1353
+ type: zod_1.default.literal("function").optional(),
1354
+ id: zod_1.default
1355
+ .string()
1356
+ .optional()
1357
+ .describe("The unique identifier of the function tool."),
1358
+ function: Function.DefinitionSchema.optional(),
1359
+ })
1360
+ .describe("A function tool call made by the assistant.");
149
1361
  let Function;
150
1362
  (function (Function) {
151
1363
  function merged(a, b) {
152
1364
  const index = a.index;
1365
+ const [type, typeChanged] = merge(a.type, b.type);
153
1366
  const [id, idChanged] = merge(a.id, b.id);
154
1367
  const [function_, functionChanged] = merge(a.function, b.function, Definition.merged);
155
- const [type, typeChanged] = merge(a.type, b.type);
156
1368
  if (idChanged || functionChanged || typeChanged) {
157
1369
  return [
158
1370
  Object.assign(Object.assign(Object.assign({ index }, (id !== undefined ? { id } : {})), (function_ !== undefined ? { function: function_ } : {})), (type !== undefined ? { type } : {})),
@@ -164,6 +1376,13 @@ var Chat;
164
1376
  }
165
1377
  }
166
1378
  Function.merged = merged;
1379
+ Function.DefinitionSchema = zod_1.default.object({
1380
+ name: zod_1.default.string().optional().describe("The name of the function."),
1381
+ arguments: zod_1.default
1382
+ .string()
1383
+ .optional()
1384
+ .describe("The arguments passed to the function."),
1385
+ });
167
1386
  let Definition;
168
1387
  (function (Definition) {
169
1388
  function merged(a, b) {
@@ -185,59 +1404,48 @@ var Chat;
185
1404
  })(Definition = Function.Definition || (Function.Definition = {}));
186
1405
  })(Function = ToolCall.Function || (ToolCall.Function = {}));
187
1406
  })(ToolCall = Streaming.ToolCall || (Streaming.ToolCall = {}));
188
- })(Streaming = Response.Streaming || (Response.Streaming = {}));
189
- let Usage;
190
- (function (Usage) {
191
- function merged(a, b) {
192
- const [completion_tokens, completion_tokensChanged] = merge(a.completion_tokens, b.completion_tokens, mergedNumber);
193
- const [prompt_tokens, prompt_tokensChanged] = merge(a.prompt_tokens, b.prompt_tokens, mergedNumber);
194
- const [total_tokens, total_tokensChanged] = merge(a.total_tokens, b.total_tokens, mergedNumber);
195
- const [completion_tokens_details, completion_tokens_detailsChanged] = merge(a.completion_tokens_details, b.completion_tokens_details, CompletionTokensDetails.merged);
196
- const [prompt_tokens_details, prompt_tokens_detailsChanged] = merge(a.prompt_tokens_details, b.prompt_tokens_details, PromptTokensDetails.merged);
197
- const [cost, costChanged] = merge(a.cost, b.cost, mergedNumber);
198
- const [cost_details, cost_detailsChanged] = merge(a.cost_details, b.cost_details, CostDetails.merged);
199
- if (completion_tokensChanged ||
200
- prompt_tokensChanged ||
201
- total_tokensChanged ||
202
- completion_tokens_detailsChanged ||
203
- prompt_tokens_detailsChanged ||
204
- costChanged ||
205
- cost_detailsChanged) {
206
- return [
207
- Object.assign(Object.assign(Object.assign(Object.assign({ completion_tokens,
208
- prompt_tokens,
209
- total_tokens }, (completion_tokens_details !== undefined
210
- ? { completion_tokens_details }
211
- : {})), (prompt_tokens_details !== undefined
212
- ? { prompt_tokens_details }
213
- : {})), (cost !== undefined ? { cost } : {})), (cost_details !== undefined ? { cost_details } : {})),
214
- true,
215
- ];
216
- }
217
- else {
218
- return [a, false];
219
- }
220
- }
221
- Usage.merged = merged;
222
- let CompletionTokensDetails;
223
- (function (CompletionTokensDetails) {
1407
+ Streaming.DeltaSchema = zod_1.default
1408
+ .object({
1409
+ content: zod_1.default
1410
+ .string()
1411
+ .optional()
1412
+ .describe("The content added in this delta."),
1413
+ refusal: zod_1.default
1414
+ .string()
1415
+ .optional()
1416
+ .describe("The refusal message added in this delta."),
1417
+ role: Response.RoleSchema.optional(),
1418
+ tool_calls: zod_1.default
1419
+ .array(Streaming.ToolCallSchema)
1420
+ .optional()
1421
+ .describe("Tool calls made in this delta."),
1422
+ reasoning: zod_1.default
1423
+ .string()
1424
+ .optional()
1425
+ .describe("The reasoning added in this delta."),
1426
+ images: zod_1.default
1427
+ .array(Response.ImageSchema)
1428
+ .optional()
1429
+ .describe("Images added in this delta."),
1430
+ })
1431
+ .describe("A delta in a streaming chat completion response.");
1432
+ let Delta;
1433
+ (function (Delta) {
224
1434
  function merged(a, b) {
225
- const [accepted_prediction_tokens, accepted_prediction_tokensChanged,] = merge(a.accepted_prediction_tokens, b.accepted_prediction_tokens, mergedNumber);
226
- const [audio_tokens, audio_tokensChanged] = merge(a.audio_tokens, b.audio_tokens, mergedNumber);
227
- const [reasoning_tokens, reasoning_tokensChanged] = merge(a.reasoning_tokens, b.reasoning_tokens, mergedNumber);
228
- const [rejected_prediction_tokens, rejected_prediction_tokensChanged,] = merge(a.rejected_prediction_tokens, b.rejected_prediction_tokens, mergedNumber);
229
- if (accepted_prediction_tokensChanged ||
230
- audio_tokensChanged ||
231
- reasoning_tokensChanged ||
232
- rejected_prediction_tokensChanged) {
1435
+ const [content, contentChanged] = merge(a.content, b.content, mergedString);
1436
+ const [refusal, refusalChanged] = merge(a.refusal, b.refusal, mergedString);
1437
+ const [role, roleChanged] = merge(a.role, b.role);
1438
+ const [tool_calls, tool_callsChanged] = merge(a.tool_calls, b.tool_calls, ToolCall.mergedList);
1439
+ const [reasoning, reasoningChanged] = merge(a.reasoning, b.reasoning, mergedString);
1440
+ const [images, imagesChanged] = merge(a.images, b.images, Image.mergedList);
1441
+ if (contentChanged ||
1442
+ reasoningChanged ||
1443
+ refusalChanged ||
1444
+ roleChanged ||
1445
+ tool_callsChanged ||
1446
+ imagesChanged) {
233
1447
  return [
234
- Object.assign(Object.assign(Object.assign(Object.assign({}, (accepted_prediction_tokens !== undefined
235
- ? { accepted_prediction_tokens }
236
- : {})), (audio_tokens !== undefined ? { audio_tokens } : {})), (reasoning_tokens !== undefined
237
- ? { reasoning_tokens }
238
- : {})), (rejected_prediction_tokens !== undefined
239
- ? { rejected_prediction_tokens }
240
- : {})),
1448
+ Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (content !== undefined ? { content } : {})), (reasoning !== undefined ? { reasoning } : {})), (refusal !== undefined ? { refusal } : {})), (role !== undefined ? { role } : {})), (tool_calls !== undefined ? { tool_calls } : {})), (images !== undefined ? { images } : {})),
241
1449
  true,
242
1450
  ];
243
1451
  }
@@ -245,16 +1453,30 @@ var Chat;
245
1453
  return [a, false];
246
1454
  }
247
1455
  }
248
- CompletionTokensDetails.merged = merged;
249
- })(CompletionTokensDetails = Usage.CompletionTokensDetails || (Usage.CompletionTokensDetails = {}));
250
- let PromptTokensDetails;
251
- (function (PromptTokensDetails) {
1456
+ Delta.merged = merged;
1457
+ })(Delta = Streaming.Delta || (Streaming.Delta = {}));
1458
+ Streaming.ChoiceSchema = zod_1.default
1459
+ .object({
1460
+ delta: Streaming.DeltaSchema,
1461
+ finish_reason: Response.FinishReasonSchema.optional(),
1462
+ index: zod_1.default
1463
+ .uint32()
1464
+ .describe("The index of the choice in the list of choices."),
1465
+ logprobs: Response.LogprobsSchema.optional(),
1466
+ })
1467
+ .describe("A choice in a streaming chat completion response.");
1468
+ let Choice;
1469
+ (function (Choice) {
252
1470
  function merged(a, b) {
253
- const [audio_tokens, audio_tokensChanged] = merge(a.audio_tokens, b.audio_tokens, mergedNumber);
254
- const [cached_tokens, cached_tokensChanged] = merge(a.cached_tokens, b.cached_tokens, mergedNumber);
255
- if (audio_tokensChanged || cached_tokensChanged) {
1471
+ const [delta, deltaChanged] = merge(a.delta, b.delta, Delta.merged);
1472
+ const [finish_reason, finish_reasonChanged] = merge(a.finish_reason, b.finish_reason);
1473
+ const index = a.index;
1474
+ const [logprobs, logprobsChanged] = merge(a.logprobs, b.logprobs, Logprobs.merged);
1475
+ if (deltaChanged || finish_reasonChanged || logprobsChanged) {
256
1476
  return [
257
- Object.assign(Object.assign({}, (audio_tokens !== undefined ? { audio_tokens } : {})), (cached_tokens !== undefined ? { cached_tokens } : {})),
1477
+ Object.assign({ delta,
1478
+ finish_reason,
1479
+ index }, (logprobs !== undefined ? { logprobs } : {})),
258
1480
  true,
259
1481
  ];
260
1482
  }
@@ -262,21 +1484,92 @@ var Chat;
262
1484
  return [a, false];
263
1485
  }
264
1486
  }
265
- PromptTokensDetails.merged = merged;
266
- })(PromptTokensDetails = Usage.PromptTokensDetails || (Usage.PromptTokensDetails = {}));
267
- let CostDetails;
268
- (function (CostDetails) {
1487
+ Choice.merged = merged;
1488
+ function mergedList(a, b) {
1489
+ let merged = undefined;
1490
+ for (const choice of b) {
1491
+ const existingIndex = a.findIndex(({ index }) => index === choice.index);
1492
+ if (existingIndex === -1) {
1493
+ if (merged === undefined) {
1494
+ merged = [...a, choice];
1495
+ }
1496
+ else {
1497
+ merged.push(choice);
1498
+ }
1499
+ }
1500
+ else {
1501
+ const [mergedChoice, choiceChanged] = Choice.merged(a[existingIndex], choice);
1502
+ if (choiceChanged) {
1503
+ if (merged === undefined) {
1504
+ merged = [...a];
1505
+ }
1506
+ merged[existingIndex] = mergedChoice;
1507
+ }
1508
+ }
1509
+ }
1510
+ return merged ? [merged, true] : [a, false];
1511
+ }
1512
+ Choice.mergedList = mergedList;
1513
+ })(Choice = Streaming.Choice || (Streaming.Choice = {}));
1514
+ Streaming.ChatCompletionChunkSchema = zod_1.default
1515
+ .object({
1516
+ id: zod_1.default
1517
+ .string()
1518
+ .describe("The unique identifier of the chat completion."),
1519
+ upstream_id: zod_1.default
1520
+ .string()
1521
+ .describe("The unique identifier of the upstream chat completion."),
1522
+ choices: zod_1.default
1523
+ .array(Streaming.ChoiceSchema)
1524
+ .describe("The list of choices in this chunk."),
1525
+ created: zod_1.default
1526
+ .uint32()
1527
+ .describe("The Unix timestamp (in seconds) when the chat completion was created."),
1528
+ model: zod_1.default
1529
+ .string()
1530
+ .describe("The unique identifier of the Ensemble LLM used for this chat completion."),
1531
+ upstream_model: zod_1.default
1532
+ .string()
1533
+ .describe("The upstream model used for this chat completion."),
1534
+ object: zod_1.default.literal("chat.completion.chunk"),
1535
+ service_tier: zod_1.default.string().optional(),
1536
+ system_fingerprint: zod_1.default.string().optional(),
1537
+ usage: Response.UsageSchema.optional(),
1538
+ provider: zod_1.default
1539
+ .string()
1540
+ .optional()
1541
+ .describe("The provider used for this chat completion."),
1542
+ })
1543
+ .describe("A chunk in a streaming chat completion response.");
1544
+ let ChatCompletionChunk;
1545
+ (function (ChatCompletionChunk) {
269
1546
  function merged(a, b) {
270
- const [upstream_inference_cost, upstream_inference_costChanged] = merge(a.upstream_inference_cost, b.upstream_inference_cost, mergedNumber);
271
- const [upstream_upstream_inference_cost, upstream_upstream_inference_costChanged,] = merge(a.upstream_upstream_inference_cost, b.upstream_upstream_inference_cost, mergedNumber);
272
- if (upstream_inference_costChanged ||
273
- upstream_upstream_inference_costChanged) {
1547
+ const id = a.id;
1548
+ const upstream_id = a.upstream_id;
1549
+ const [choices, choicesChanged] = Choice.mergedList(a.choices, b.choices);
1550
+ const created = a.created;
1551
+ const model = a.model;
1552
+ const upstream_model = a.upstream_model;
1553
+ const object = a.object;
1554
+ const [service_tier, service_tierChanged] = merge(a.service_tier, b.service_tier);
1555
+ const [system_fingerprint, system_fingerprintChanged] = merge(a.system_fingerprint, b.system_fingerprint);
1556
+ const [usage, usageChanged] = merge(a.usage, b.usage);
1557
+ const [provider, providerChanged] = merge(a.provider, b.provider);
1558
+ if (choicesChanged ||
1559
+ service_tierChanged ||
1560
+ system_fingerprintChanged ||
1561
+ usageChanged ||
1562
+ providerChanged) {
274
1563
  return [
275
- Object.assign(Object.assign({}, (upstream_inference_cost !== undefined
276
- ? { upstream_inference_cost }
277
- : {})), (upstream_upstream_inference_cost !== undefined
278
- ? { upstream_upstream_inference_cost }
279
- : {})),
1564
+ Object.assign(Object.assign(Object.assign(Object.assign({ id,
1565
+ upstream_id,
1566
+ choices,
1567
+ created,
1568
+ model,
1569
+ upstream_model,
1570
+ object }, (service_tier !== undefined ? { service_tier } : {})), (system_fingerprint !== undefined
1571
+ ? { system_fingerprint }
1572
+ : {})), (usage !== undefined ? { usage } : {})), (provider !== undefined ? { provider } : {})),
280
1573
  true,
281
1574
  ];
282
1575
  }
@@ -284,68 +1577,106 @@ var Chat;
284
1577
  return [a, false];
285
1578
  }
286
1579
  }
287
- CostDetails.merged = merged;
288
- })(CostDetails = Usage.CostDetails || (Usage.CostDetails = {}));
289
- })(Usage = Response.Usage || (Response.Usage = {}));
290
- let Logprobs;
291
- (function (Logprobs) {
292
- function merged(a, b) {
293
- const [content, contentChanged] = merge(a.content, b.content, Logprob.mergedList);
294
- const [refusal, refusalChanged] = merge(a.refusal, b.refusal, Logprob.mergedList);
295
- if (contentChanged || refusalChanged) {
296
- return [{ content, refusal }, true];
297
- }
298
- else {
299
- return [a, false];
300
- }
301
- }
302
- Logprobs.merged = merged;
303
- let Logprob;
304
- (function (Logprob) {
305
- function mergedList(a, b) {
306
- if (b.length === 0) {
307
- return [a, false];
308
- }
309
- else if (a.length === 0) {
310
- return [b, true];
311
- }
312
- else {
313
- return [[...a, ...b], true];
314
- }
315
- }
316
- Logprob.mergedList = mergedList;
317
- })(Logprob = Logprobs.Logprob || (Logprobs.Logprob = {}));
318
- })(Logprobs = Response.Logprobs || (Response.Logprobs = {}));
319
- let Image;
320
- (function (Image) {
321
- function mergedList(a, b) {
322
- if (b.length === 0) {
323
- return [a, false];
324
- }
325
- else if (a.length === 0) {
326
- return [b, true];
327
- }
328
- else {
329
- return [[...a, ...b], true];
330
- }
331
- }
332
- Image.mergedList = mergedList;
333
- })(Image = Response.Image || (Response.Image = {}));
1580
+ ChatCompletionChunk.merged = merged;
1581
+ })(ChatCompletionChunk = Streaming.ChatCompletionChunk || (Streaming.ChatCompletionChunk = {}));
1582
+ })(Streaming = Response.Streaming || (Response.Streaming = {}));
1583
+ let Unary;
1584
+ (function (Unary) {
1585
+ Unary.ToolCallSchema = zod_1.default
1586
+ .union([ToolCall.FunctionSchema])
1587
+ .describe(Streaming.ToolCallSchema.description);
1588
+ let ToolCall;
1589
+ (function (ToolCall) {
1590
+ ToolCall.FunctionSchema = zod_1.default
1591
+ .object({
1592
+ type: zod_1.default.literal("function"),
1593
+ id: zod_1.default
1594
+ .string()
1595
+ .describe(Streaming.ToolCall.FunctionSchema.shape.id.description),
1596
+ function: Function.DefinitionSchema,
1597
+ })
1598
+ .describe(Streaming.ToolCall.FunctionSchema.description);
1599
+ let Function;
1600
+ (function (Function) {
1601
+ Function.DefinitionSchema = zod_1.default.object({
1602
+ name: zod_1.default
1603
+ .string()
1604
+ .describe(Streaming.ToolCall.Function.DefinitionSchema.shape.name
1605
+ .description),
1606
+ arguments: zod_1.default
1607
+ .string()
1608
+ .describe(Streaming.ToolCall.Function.DefinitionSchema.shape.arguments
1609
+ .description),
1610
+ });
1611
+ })(Function = ToolCall.Function || (ToolCall.Function = {}));
1612
+ })(ToolCall = Unary.ToolCall || (Unary.ToolCall = {}));
1613
+ Unary.MessageSchema = zod_1.default
1614
+ .object({
1615
+ content: zod_1.default
1616
+ .string()
1617
+ .nullable()
1618
+ .describe("The content of the message."),
1619
+ refusal: zod_1.default
1620
+ .string()
1621
+ .nullable()
1622
+ .describe("The refusal message, if any."),
1623
+ role: Response.RoleSchema,
1624
+ tool_calls: zod_1.default
1625
+ .array(Unary.ToolCallSchema)
1626
+ .nullable()
1627
+ .describe("The tool calls made by the assistant, if any."),
1628
+ reasoning: zod_1.default
1629
+ .string()
1630
+ .optional()
1631
+ .describe("The reasoning provided by the assistant, if any."),
1632
+ images: zod_1.default
1633
+ .array(Response.ImageSchema)
1634
+ .optional()
1635
+ .describe("The images generated by the assistant, if any."),
1636
+ })
1637
+ .describe("A message generated by the assistant.");
1638
+ Unary.ChoiceSchema = zod_1.default
1639
+ .object({
1640
+ message: Unary.MessageSchema,
1641
+ finish_reason: Response.FinishReasonSchema,
1642
+ index: zod_1.default
1643
+ .uint32()
1644
+ .describe(Streaming.ChoiceSchema.shape.index.description),
1645
+ logprobs: Response.LogprobsSchema.nullable(),
1646
+ })
1647
+ .describe("A choice in a unary chat completion response.");
1648
+ Unary.ChatCompletionSchema = zod_1.default
1649
+ .object({
1650
+ id: zod_1.default
1651
+ .string()
1652
+ .describe("The unique identifier of the chat completion."),
1653
+ upstream_id: zod_1.default
1654
+ .string()
1655
+ .describe("The unique identifier of the upstream chat completion."),
1656
+ choices: zod_1.default
1657
+ .array(Unary.ChoiceSchema)
1658
+ .describe("The list of choices in this chat completion."),
1659
+ created: zod_1.default
1660
+ .uint32()
1661
+ .describe("The Unix timestamp (in seconds) when the chat completion was created."),
1662
+ model: zod_1.default
1663
+ .string()
1664
+ .describe("The unique identifier of the Ensemble LLM used for this chat completion."),
1665
+ upstream_model: zod_1.default
1666
+ .string()
1667
+ .describe("The upstream model used for this chat completion."),
1668
+ object: zod_1.default.literal("chat.completion"),
1669
+ service_tier: zod_1.default.string().optional(),
1670
+ system_fingerprint: zod_1.default.string().optional(),
1671
+ usage: Response.UsageSchema,
1672
+ provider: zod_1.default
1673
+ .string()
1674
+ .optional()
1675
+ .describe("The provider used for this chat completion."),
1676
+ })
1677
+ .describe("A unary chat completion response.");
1678
+ })(Unary = Response.Unary || (Response.Unary = {}));
334
1679
  })(Response = Completions.Response || (Completions.Response = {}));
335
- async function list(openai, listOptions, options) {
336
- const response = await openai.chat.completions.list(Object.assign({ query: listOptions }, options));
337
- return response;
338
- }
339
- Completions.list = list;
340
- async function publish(openai, id, options) {
341
- await openai.post(`/chat/completions/${id}/publish`, options);
342
- }
343
- Completions.publish = publish;
344
- async function retrieve(openai, id, options) {
345
- const response = await openai.chat.completions.retrieve(id, options);
346
- return response;
347
- }
348
- Completions.retrieve = retrieve;
349
1680
  async function create(openai, body, options) {
350
1681
  var _a;
351
1682
  const response = await openai.post("/chat/completions", Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
@@ -354,68 +1685,146 @@ var Chat;
354
1685
  Completions.create = create;
355
1686
  })(Completions = Chat.Completions || (Chat.Completions = {}));
356
1687
  })(Chat || (exports.Chat = Chat = {}));
357
- var Score;
358
- (function (Score) {
1688
+ // Vector Completions
1689
+ var Vector;
1690
+ (function (Vector) {
359
1691
  let Completions;
360
1692
  (function (Completions) {
1693
+ let Request;
1694
+ (function (Request) {
1695
+ Request.EnsembleSchema = zod_1.default
1696
+ .union([zod_1.default.string(), exports.EnsembleBaseSchema])
1697
+ .describe("The Ensemble to use for this completion. May be a unique ID or an inline definition.");
1698
+ Request.ProfileSchema = zod_1.default
1699
+ .array(zod_1.default.number())
1700
+ .describe('The profile to use for the completion. Must be of the same length as the Ensemble\'s "LLMs" field, ignoring count.');
1701
+ Request.VectorCompletionCreateParamsBaseSchema = zod_1.default
1702
+ .object({
1703
+ retry: zod_1.default
1704
+ .string()
1705
+ .optional()
1706
+ .nullable()
1707
+ .describe("The unique ID of a previous incomplete or failed completion."),
1708
+ messages: exports.MessagesSchema,
1709
+ provider: Chat.Completions.Request.ProviderSchema.optional().nullable(),
1710
+ ensemble: Request.EnsembleSchema,
1711
+ profile: Request.ProfileSchema,
1712
+ seed: Chat.Completions.Request.SeedSchema.optional().nullable(),
1713
+ tools: exports.ToolsSchema.optional()
1714
+ .nullable()
1715
+ .describe(`${exports.ToolsSchema.description} These are readonly and will only be useful for explaining prior tool calls or otherwise influencing behavior.`),
1716
+ responses: exports.VectorResponsesSchema,
1717
+ backoff_max_elapsed_time: Chat.Completions.Request.BackoffMaxElapsedTimeSchema.optional().nullable(),
1718
+ first_chunk_timeout: Chat.Completions.Request.FirstChunkTimeoutSchema.optional().nullable(),
1719
+ other_chunk_timeout: Chat.Completions.Request.OtherChunkTimeoutSchema.optional().nullable(),
1720
+ })
1721
+ .describe("Base parameters for creating a vector completion.");
1722
+ Request.VectorCompletionCreateParamsStreamingSchema = Request.VectorCompletionCreateParamsBaseSchema.extend({
1723
+ stream: Chat.Completions.Request.StreamTrueSchema,
1724
+ }).describe("Parameters for creating a streaming vector completion.");
1725
+ Request.VectorCompletionCreateParamsNonStreamingSchema = Request.VectorCompletionCreateParamsBaseSchema.extend({
1726
+ stream: Chat.Completions.Request.StreamFalseSchema.optional().nullable(),
1727
+ }).describe("Parameters for creating a unary vector completion.");
1728
+ Request.VectorCompletionCreateParamsSchema = zod_1.default
1729
+ .union([
1730
+ Request.VectorCompletionCreateParamsStreamingSchema,
1731
+ Request.VectorCompletionCreateParamsNonStreamingSchema,
1732
+ ])
1733
+ .describe("Parameters for creating a vector completion.");
1734
+ })(Request = Completions.Request || (Completions.Request = {}));
361
1735
  let Response;
362
1736
  (function (Response) {
1737
+ Response.VoteSchema = zod_1.default
1738
+ .object({
1739
+ model: zod_1.default
1740
+ .string()
1741
+ .describe("The unique identifier of the Ensemble LLM which generated this vote."),
1742
+ ensemble_index: zod_1.default
1743
+ .uint32()
1744
+ .describe("The index of the Ensemble LLM in the Ensemble."),
1745
+ flat_ensemble_index: zod_1.default
1746
+ .uint32()
1747
+ .describe("The flat index of the Ensemble LLM in the expanded Ensemble, accounting for counts."),
1748
+ vote: zod_1.default
1749
+ .array(zod_1.default.number())
1750
+ .describe("The vote generated by this Ensemble LLM. It is of the same length of the number of responses provided in the request. If the Ensemble LLM used logprobs, may be a probability distribution; otherwise, one of the responses will have a value of 1 and the rest 0."),
1751
+ weight: zod_1.default.number().describe("The weight assigned to this vote."),
1752
+ retry: zod_1.default
1753
+ .boolean()
1754
+ .optional()
1755
+ .describe("Whether this vote came from a previous Vector Completion which was retried."),
1756
+ })
1757
+ .describe("A vote from an Ensemble LLM within a Vector Completion.");
1758
+ let Vote;
1759
+ (function (Vote) {
1760
+ function mergedList(a, b) {
1761
+ let merged = undefined;
1762
+ for (const vote of b) {
1763
+ const existingIndex = a.findIndex(({ flat_ensemble_index }) => flat_ensemble_index === vote.flat_ensemble_index);
1764
+ if (existingIndex === -1) {
1765
+ if (merged === undefined) {
1766
+ merged = [...a, vote];
1767
+ }
1768
+ else {
1769
+ merged.push(vote);
1770
+ }
1771
+ }
1772
+ }
1773
+ return merged ? [merged, true] : [a, false];
1774
+ }
1775
+ Vote.mergedList = mergedList;
1776
+ })(Vote = Response.Vote || (Response.Vote = {}));
1777
+ Response.UsageSchema = zod_1.default
1778
+ .object({
1779
+ completion_tokens: zod_1.default
1780
+ .uint32()
1781
+ .describe("The number of tokens generated in the completion."),
1782
+ prompt_tokens: zod_1.default
1783
+ .uint32()
1784
+ .describe("The number of tokens in the prompt."),
1785
+ total_tokens: zod_1.default
1786
+ .uint32()
1787
+ .describe("The total number of tokens used in the prompt or generated in the completion."),
1788
+ completion_tokens_details: Chat.Completions.Response.Usage.CompletionTokensDetailsSchema.optional(),
1789
+ prompt_tokens_details: Chat.Completions.Response.Usage.PromptTokensDetailsSchema.optional(),
1790
+ cost: zod_1.default
1791
+ .number()
1792
+ .describe("The cost in credits incurred for this completion."),
1793
+ cost_details: Chat.Completions.Response.Usage.CostDetailsSchema.optional(),
1794
+ total_cost: zod_1.default
1795
+ .number()
1796
+ .describe("The total cost in credits incurred including upstream costs."),
1797
+ })
1798
+ .describe("Token and cost usage statistics for the completion.");
1799
+ Response.VotesSchema = zod_1.default
1800
+ .array(Response.VoteSchema)
1801
+ .describe("The list of votes for responses in the request from the Ensemble LLMs within the provided Ensemble.");
1802
+ Response.ScoresSchema = zod_1.default
1803
+ .array(zod_1.default.number())
1804
+ .describe("The scores for each response in the request, aggregated from the votes of the Ensemble LLMs.");
1805
+ Response.WeightsSchema = zod_1.default
1806
+ .array(zod_1.default.number())
1807
+ .describe("The weights assigned to each response in the request, aggregated from the votes of the Ensemble LLMs.");
1808
+ Response.EnsembleSchema = zod_1.default
1809
+ .string()
1810
+ .describe("The unique identifier of the Ensemble used for this vector completion.");
363
1811
  let Streaming;
364
1812
  (function (Streaming) {
1813
+ Streaming.ChatCompletionChunkSchema = Chat.Completions.Response.Streaming.ChatCompletionChunkSchema.extend({
1814
+ index: zod_1.default
1815
+ .uint32()
1816
+ .describe("The index of the completion amongst all chat completions."),
1817
+ error: exports.ObjectiveAIErrorSchema.optional().describe("An error encountered during the generation of this chat completion."),
1818
+ }).describe("A chat completion chunk generated in the pursuit of a vector completion.");
365
1819
  let ChatCompletionChunk;
366
1820
  (function (ChatCompletionChunk) {
367
1821
  function merged(a, b) {
368
- const id = a.id;
369
- const [choices, choicesChanged] = Choice.mergedList(a.choices, b.choices);
370
- const created = a.created;
371
- const model = a.model;
372
- const object = a.object;
373
- const [usage, usageChanged] = merge(a.usage, b.usage, Chat.Completions.Response.Usage.merged);
374
- const [weight_data, weight_dataChanged] = merge(a.weight_data, b.weight_data);
375
- if (choicesChanged || usageChanged || weight_dataChanged) {
376
- return [
377
- Object.assign(Object.assign({ id,
378
- choices,
379
- created,
380
- model,
381
- object }, (usage !== undefined ? { usage } : {})), (weight_data !== undefined ? { weight_data } : {})),
382
- true,
383
- ];
384
- }
385
- else {
386
- return [a, false];
387
- }
388
- }
389
- ChatCompletionChunk.merged = merged;
390
- })(ChatCompletionChunk = Streaming.ChatCompletionChunk || (Streaming.ChatCompletionChunk = {}));
391
- let Choice;
392
- (function (Choice) {
393
- function merged(a, b) {
394
- const [delta, deltaChanged] = merge(a.delta, b.delta, Delta.merged);
395
- const [finish_reason, finish_reasonChanged] = merge(a.finish_reason, b.finish_reason);
396
1822
  const index = a.index;
397
- const [logprobs, logprobsChanged] = merge(a.logprobs, b.logprobs, Chat.Completions.Response.Logprobs.merged);
398
- const [weight, weightChanged] = merge(a.weight, b.weight);
399
- const [confidence, confidenceChanged] = merge(a.confidence, b.confidence);
1823
+ const [base, baseChanged] = Chat.Completions.Response.Streaming.ChatCompletionChunk.merged(a, b);
400
1824
  const [error, errorChanged] = merge(a.error, b.error);
401
- const [model, modelChanged] = merge(a.model, b.model);
402
- const [model_index, model_indexChanged] = merge(a.model_index, b.model_index);
403
- const [completion_metadata, completion_metadataChanged] = merge(a.completion_metadata, b.completion_metadata, CompletionMetadata.merged);
404
- if (deltaChanged ||
405
- finish_reasonChanged ||
406
- logprobsChanged ||
407
- weightChanged ||
408
- confidenceChanged ||
409
- errorChanged ||
410
- modelChanged ||
411
- model_indexChanged ||
412
- completion_metadataChanged) {
1825
+ if (baseChanged || errorChanged) {
413
1826
  return [
414
- Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ delta,
415
- finish_reason,
416
- index }, (logprobs !== undefined ? { logprobs } : {})), (weight !== undefined ? { weight } : {})), (confidence !== undefined ? { confidence } : {})), (error !== undefined ? { error } : {})), (model !== undefined ? { model } : {})), (model_index !== undefined ? { model_index } : {})), (completion_metadata !== undefined
417
- ? { completion_metadata }
418
- : {})),
1827
+ Object.assign(Object.assign({ index }, base), (error !== undefined ? { error } : {})),
419
1828
  true,
420
1829
  ];
421
1830
  }
@@ -423,52 +1832,78 @@ var Score;
423
1832
  return [a, false];
424
1833
  }
425
1834
  }
426
- Choice.merged = merged;
1835
+ ChatCompletionChunk.merged = merged;
427
1836
  function mergedList(a, b) {
428
1837
  let merged = undefined;
429
- for (const choice of b) {
430
- const existingIndex = a.findIndex(({ index }) => index === choice.index);
1838
+ for (const chunk of b) {
1839
+ const existingIndex = a.findIndex(({ index }) => index === chunk.index);
431
1840
  if (existingIndex === -1) {
432
1841
  if (merged === undefined) {
433
- merged = [...a, choice];
1842
+ merged = [...a, chunk];
434
1843
  }
435
1844
  else {
436
- merged.push(choice);
1845
+ merged.push(chunk);
437
1846
  }
438
1847
  }
439
1848
  else {
440
- const [mergedChoice, choiceChanged] = Choice.merged(a[existingIndex], choice);
441
- if (choiceChanged) {
1849
+ const [mergedChunk, chunkChanged] = ChatCompletionChunk.merged(a[existingIndex], chunk);
1850
+ if (chunkChanged) {
442
1851
  if (merged === undefined) {
443
1852
  merged = [...a];
444
1853
  }
445
- merged[existingIndex] = mergedChoice;
1854
+ merged[existingIndex] = mergedChunk;
446
1855
  }
447
1856
  }
448
1857
  }
449
1858
  return merged ? [merged, true] : [a, false];
450
1859
  }
451
- Choice.mergedList = mergedList;
452
- })(Choice = Streaming.Choice || (Streaming.Choice = {}));
453
- let Delta;
454
- (function (Delta) {
1860
+ ChatCompletionChunk.mergedList = mergedList;
1861
+ })(ChatCompletionChunk = Streaming.ChatCompletionChunk || (Streaming.ChatCompletionChunk = {}));
1862
+ Streaming.VectorCompletionChunkSchema = zod_1.default
1863
+ .object({
1864
+ id: zod_1.default
1865
+ .string()
1866
+ .describe("The unique identifier of the vector completion."),
1867
+ completions: zod_1.default
1868
+ .array(Streaming.ChatCompletionChunkSchema)
1869
+ .describe("The list of chat completion chunks created for this vector completion."),
1870
+ votes: Response.VotesSchema,
1871
+ scores: Response.ScoresSchema,
1872
+ weights: Response.WeightsSchema,
1873
+ created: zod_1.default
1874
+ .uint32()
1875
+ .describe("The Unix timestamp (in seconds) when the vector completion was created."),
1876
+ ensemble: Response.EnsembleSchema,
1877
+ object: zod_1.default.literal("vector.completion.chunk"),
1878
+ usage: Response.UsageSchema.optional(),
1879
+ })
1880
+ .describe("A chunk in a streaming vector completion response.");
1881
+ let VectorCompletionChunk;
1882
+ (function (VectorCompletionChunk) {
455
1883
  function merged(a, b) {
456
- const [content, contentChanged] = merge(a.content, b.content, mergedString);
457
- const [refusal, refusalChanged] = merge(a.refusal, b.refusal, mergedString);
458
- const [role, roleChanged] = merge(a.role, b.role);
459
- const [tool_calls, tool_callsChanged] = merge(a.tool_calls, b.tool_calls, Chat.Completions.Response.Streaming.ToolCall.mergedList);
460
- const [reasoning, reasoningChanged] = merge(a.reasoning, b.reasoning, mergedString);
461
- const [images, imagesChanged] = merge(a.images, b.images, Chat.Completions.Response.Image.mergedList);
462
- const [vote, voteChanged] = merge(a.vote, b.vote);
463
- if (contentChanged ||
464
- reasoningChanged ||
465
- refusalChanged ||
466
- roleChanged ||
467
- tool_callsChanged ||
468
- imagesChanged ||
469
- voteChanged) {
1884
+ const id = a.id;
1885
+ const [completions, completionsChanged] = ChatCompletionChunk.mergedList(a.completions, b.completions);
1886
+ const [votes, votesChanged] = Vote.mergedList(a.votes, b.votes);
1887
+ const [scores, scoresChanged] = Scores.merged(a.scores, b.scores);
1888
+ const [weights, weightsChanged] = Weights.merged(a.weights, b.weights);
1889
+ const created = a.created;
1890
+ const ensemble = a.ensemble;
1891
+ const object = a.object;
1892
+ const [usage, usageChanged] = merge(a.usage, b.usage);
1893
+ if (completionsChanged ||
1894
+ votesChanged ||
1895
+ scoresChanged ||
1896
+ weightsChanged ||
1897
+ usageChanged) {
470
1898
  return [
471
- Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (content !== undefined ? { content } : {})), (reasoning !== undefined ? { reasoning } : {})), (refusal !== undefined ? { refusal } : {})), (role !== undefined ? { role } : {})), (tool_calls !== undefined ? { tool_calls } : {})), (images !== undefined ? { images } : {})), (vote !== undefined ? { vote } : {})),
1899
+ Object.assign({ id,
1900
+ completions,
1901
+ votes,
1902
+ scores,
1903
+ weights,
1904
+ created,
1905
+ ensemble,
1906
+ object }, (usage !== undefined ? { usage } : {})),
472
1907
  true,
473
1908
  ];
474
1909
  }
@@ -476,91 +1911,840 @@ var Score;
476
1911
  return [a, false];
477
1912
  }
478
1913
  }
479
- Delta.merged = merged;
480
- })(Delta = Streaming.Delta || (Streaming.Delta = {}));
481
- })(Streaming = Response.Streaming || (Response.Streaming = {}));
482
- let CompletionMetadata;
483
- (function (CompletionMetadata) {
484
- function merged(a, b) {
485
- const id = a.id;
486
- const created = a.created;
487
- const model = a.model;
488
- const [service_tier, service_tierChanged] = merge(a.service_tier, b.service_tier);
489
- const [system_fingerprint, system_fingerprintChanged] = merge(a.system_fingerprint, b.system_fingerprint);
490
- const [usage, usageChanged] = merge(a.usage, b.usage, Chat.Completions.Response.Usage.merged);
491
- if (service_tierChanged ||
492
- system_fingerprintChanged ||
493
- usageChanged) {
494
- return [
495
- Object.assign(Object.assign(Object.assign({ id,
496
- created,
497
- model }, (service_tier !== undefined ? { service_tier } : {})), (system_fingerprint !== undefined
498
- ? { system_fingerprint }
499
- : {})), (usage !== undefined ? { usage } : {})),
500
- true,
501
- ];
1914
+ VectorCompletionChunk.merged = merged;
1915
+ })(VectorCompletionChunk = Streaming.VectorCompletionChunk || (Streaming.VectorCompletionChunk = {}));
1916
+ let Scores;
1917
+ (function (Scores) {
1918
+ function merged(a, b) {
1919
+ if (a.length === b.length) {
1920
+ for (let i = 0; i < a.length; i++) {
1921
+ if (a[i] !== b[i]) {
1922
+ return [b, true];
1923
+ }
1924
+ }
1925
+ return [a, false];
1926
+ }
1927
+ else {
1928
+ return [b, true];
1929
+ }
502
1930
  }
503
- else {
504
- return [a, false];
1931
+ Scores.merged = merged;
1932
+ })(Scores = Streaming.Scores || (Streaming.Scores = {}));
1933
+ let Weights;
1934
+ (function (Weights) {
1935
+ function merged(a, b) {
1936
+ return Scores.merged(a, b);
505
1937
  }
506
- }
507
- CompletionMetadata.merged = merged;
508
- })(CompletionMetadata = Response.CompletionMetadata || (Response.CompletionMetadata = {}));
1938
+ Weights.merged = merged;
1939
+ })(Weights = Streaming.Weights || (Streaming.Weights = {}));
1940
+ })(Streaming = Response.Streaming || (Response.Streaming = {}));
1941
+ let Unary;
1942
+ (function (Unary) {
1943
+ Unary.ChatCompletionSchema = Chat.Completions.Response.Unary.ChatCompletionSchema.extend({
1944
+ index: zod_1.default
1945
+ .uint32()
1946
+ .describe("The index of the completion amongst all chat completions."),
1947
+ error: exports.ObjectiveAIErrorSchema.optional().describe("An error encountered during the generation of this chat completion."),
1948
+ }).describe("A chat completion generated in the pursuit of a vector completion.");
1949
+ Unary.VectorCompletionSchema = zod_1.default
1950
+ .object({
1951
+ id: zod_1.default
1952
+ .string()
1953
+ .describe("The unique identifier of the vector completion."),
1954
+ completions: zod_1.default
1955
+ .array(Unary.ChatCompletionSchema)
1956
+ .describe("The list of chat completions created for this vector completion."),
1957
+ votes: Response.VotesSchema,
1958
+ scores: Response.ScoresSchema,
1959
+ weights: Response.WeightsSchema,
1960
+ created: zod_1.default
1961
+ .uint32()
1962
+ .describe("The Unix timestamp (in seconds) when the vector completion was created."),
1963
+ ensemble: Response.EnsembleSchema,
1964
+ object: zod_1.default.literal("vector.completion"),
1965
+ usage: Response.UsageSchema,
1966
+ })
1967
+ .describe("A unary vector completion response.");
1968
+ })(Unary = Response.Unary || (Response.Unary = {}));
509
1969
  })(Response = Completions.Response || (Completions.Response = {}));
510
- async function list(openai, listOptions, options) {
511
- const response = await openai.get("/score/completions", Object.assign({ query: listOptions }, options));
512
- return response;
513
- }
514
- Completions.list = list;
515
- async function publish(openai, id, options) {
516
- await openai.post(`/score/completions/${id}/publish`, options);
517
- }
518
- Completions.publish = publish;
519
- async function retrieve(openai, id, options) {
520
- const response = await openai.get(`/score/completions/${id}`, options);
521
- return response;
522
- }
523
- Completions.retrieve = retrieve;
524
- async function trainingTableAdd(openai, id, correctVote, options) {
525
- await openai.post(`/score/completions/${id}/training_table`, Object.assign({ body: { correct_vote: correctVote } }, options));
526
- }
527
- Completions.trainingTableAdd = trainingTableAdd;
528
- async function trainingTableDelete(openai, id, options) {
529
- await openai.delete(`/score/completions/${id}/training_table`, options);
530
- }
531
- Completions.trainingTableDelete = trainingTableDelete;
532
1970
  async function create(openai, body, options) {
533
1971
  var _a;
534
- const response = await openai.post("/score/completions", Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
1972
+ const response = await openai.post("/vector/completions", Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
535
1973
  return response;
536
1974
  }
537
1975
  Completions.create = create;
538
- })(Completions = Score.Completions || (Score.Completions = {}));
539
- })(Score || (exports.Score = Score = {}));
540
- var Multichat;
541
- (function (Multichat) {
542
- let Completions;
543
- (function (Completions) {
1976
+ })(Completions = Vector.Completions || (Vector.Completions = {}));
1977
+ })(Vector || (exports.Vector = Vector = {}));
1978
+ // Function
1979
+ exports.FunctionSchema = zod_1.default
1980
+ .discriminatedUnion("type", [Function.ScalarSchema, Function.VectorSchema])
1981
+ .describe("A function.");
1982
+ var Function;
1983
+ (function (Function_1) {
1984
+ Function_1.VectorCompletionProfileSchema = zod_1.default
1985
+ .object({
1986
+ ensemble: Vector.Completions.Request.EnsembleSchema,
1987
+ profile: Vector.Completions.Request.ProfileSchema,
1988
+ })
1989
+ .describe("A vector completion profile containing an Ensemble and array of weights.");
1990
+ Function_1.FunctionProfileVersionRequiredSchema = zod_1.default
1991
+ .union([
1992
+ zod_1.default.object({
1993
+ function_author: zod_1.default
1994
+ .string()
1995
+ .describe("The author of the function the profile was published to."),
1996
+ function_id: zod_1.default
1997
+ .string()
1998
+ .describe("The unique identifier of the function the profile was published to."),
1999
+ author: zod_1.default.string().describe("The author of the profile."),
2000
+ id: zod_1.default.string().describe("The unique identifier of the profile."),
2001
+ version: zod_1.default.uint32().describe("The version of the profile."),
2002
+ }),
2003
+ zod_1.default.lazy(() => zod_1.default.array(Function_1.ProfileVersionRequiredSchema)),
2004
+ ])
2005
+ .describe("A function profile where remote profiles must specify a version.");
2006
+ Function_1.FunctionProfileVersionOptionalSchema = zod_1.default
2007
+ .union([
2008
+ zod_1.default.object({
2009
+ function_author: zod_1.default
2010
+ .string()
2011
+ .describe("The author of the function the profile was published to."),
2012
+ function_id: zod_1.default
2013
+ .string()
2014
+ .describe("The unique identifier of the function the profile was published to."),
2015
+ author: zod_1.default.string().describe("The author of the profile."),
2016
+ id: zod_1.default.string().describe("The unique identifier of the profile."),
2017
+ version: zod_1.default
2018
+ .uint32()
2019
+ .optional()
2020
+ .nullable()
2021
+ .describe("The version of the profile."),
2022
+ }),
2023
+ zod_1.default.lazy(() => zod_1.default.array(Function_1.ProfileVersionOptionalSchema)),
2024
+ ])
2025
+ .describe("A function profile where remote profiles may omit a version.");
2026
+ Function_1.ProfileVersionRequiredSchema = zod_1.default
2027
+ .union([
2028
+ Function_1.FunctionProfileVersionRequiredSchema,
2029
+ Function_1.VectorCompletionProfileSchema,
2030
+ ])
2031
+ .describe("A profile where remote function profiles must specify a version.");
2032
+ Function_1.ProfileVersionOptionalSchema = zod_1.default
2033
+ .union([
2034
+ Function_1.FunctionProfileVersionOptionalSchema,
2035
+ Function_1.VectorCompletionProfileSchema,
2036
+ ])
2037
+ .describe("A profile where remote function profiles may omit a version.");
2038
+ Function_1.InputSchemaSchema = zod_1.default.lazy(() => zod_1.default
2039
+ .union([
2040
+ InputSchema.ObjectSchema,
2041
+ InputSchema.ArraySchema,
2042
+ InputSchema.StringSchema,
2043
+ InputSchema.NumberSchema,
2044
+ InputSchema.IntegerSchema,
2045
+ InputSchema.BooleanSchema,
2046
+ InputSchema.ImageSchema,
2047
+ InputSchema.AudioSchema,
2048
+ InputSchema.VideoSchema,
2049
+ InputSchema.FileSchema,
2050
+ ])
2051
+ .describe("An input schema defining the structure of function inputs."));
2052
+ let InputSchema;
2053
+ (function (InputSchema) {
2054
+ InputSchema.ObjectSchema = zod_1.default
2055
+ .object({
2056
+ type: zod_1.default.literal("object"),
2057
+ description: zod_1.default
2058
+ .string()
2059
+ .optional()
2060
+ .nullable()
2061
+ .describe("The description of the object input."),
2062
+ properties: zod_1.default
2063
+ .record(zod_1.default.string(), Function_1.InputSchemaSchema)
2064
+ .describe("The properties of the object input."),
2065
+ required: zod_1.default
2066
+ .array(zod_1.default.string())
2067
+ .optional()
2068
+ .nullable()
2069
+ .describe("The required properties of the object input."),
2070
+ })
2071
+ .describe("An object input schema.");
2072
+ InputSchema.ArraySchema = zod_1.default
2073
+ .object({
2074
+ type: zod_1.default.literal("array"),
2075
+ description: zod_1.default
2076
+ .string()
2077
+ .optional()
2078
+ .nullable()
2079
+ .describe("The description of the array input."),
2080
+ minItems: zod_1.default
2081
+ .uint32()
2082
+ .optional()
2083
+ .nullable()
2084
+ .describe("The minimum number of items in the array input."),
2085
+ maxItems: zod_1.default
2086
+ .uint32()
2087
+ .optional()
2088
+ .nullable()
2089
+ .describe("The maximum number of items in the array input."),
2090
+ items: Function_1.InputSchemaSchema.describe("The schema of the items in the array input."),
2091
+ })
2092
+ .describe("An array input schema.");
2093
+ InputSchema.StringSchema = zod_1.default
2094
+ .object({
2095
+ type: zod_1.default.literal("string"),
2096
+ description: zod_1.default
2097
+ .string()
2098
+ .optional()
2099
+ .nullable()
2100
+ .describe("The description of the string input."),
2101
+ enum: zod_1.default
2102
+ .array(zod_1.default.string())
2103
+ .optional()
2104
+ .nullable()
2105
+ .describe("The enumeration of allowed string values."),
2106
+ })
2107
+ .describe("A string input schema.");
2108
+ InputSchema.NumberSchema = zod_1.default
2109
+ .object({
2110
+ type: zod_1.default.literal("number"),
2111
+ description: zod_1.default
2112
+ .string()
2113
+ .optional()
2114
+ .nullable()
2115
+ .describe("The description of the number input."),
2116
+ minimum: zod_1.default
2117
+ .number()
2118
+ .optional()
2119
+ .nullable()
2120
+ .describe("The minimum allowed value for the number input."),
2121
+ maximum: zod_1.default
2122
+ .number()
2123
+ .optional()
2124
+ .nullable()
2125
+ .describe("The maximum allowed value for the number input."),
2126
+ })
2127
+ .describe("A number input schema.");
2128
+ InputSchema.IntegerSchema = zod_1.default
2129
+ .object({
2130
+ type: zod_1.default.literal("integer"),
2131
+ description: zod_1.default
2132
+ .string()
2133
+ .optional()
2134
+ .nullable()
2135
+ .describe("The description of the integer input."),
2136
+ minimum: zod_1.default
2137
+ .uint32()
2138
+ .optional()
2139
+ .nullable()
2140
+ .describe("The minimum allowed value for the integer input."),
2141
+ maximum: zod_1.default
2142
+ .uint32()
2143
+ .optional()
2144
+ .nullable()
2145
+ .describe("The maximum allowed value for the integer input."),
2146
+ })
2147
+ .describe("An integer input schema.");
2148
+ InputSchema.BooleanSchema = zod_1.default
2149
+ .object({
2150
+ type: zod_1.default.literal("boolean"),
2151
+ description: zod_1.default
2152
+ .string()
2153
+ .optional()
2154
+ .nullable()
2155
+ .describe("The description of the boolean input."),
2156
+ })
2157
+ .describe("A boolean input schema.");
2158
+ InputSchema.ImageSchema = zod_1.default
2159
+ .object({
2160
+ type: zod_1.default.literal("image"),
2161
+ description: zod_1.default
2162
+ .string()
2163
+ .optional()
2164
+ .nullable()
2165
+ .describe("The description of the image input."),
2166
+ })
2167
+ .describe("An image input schema.");
2168
+ InputSchema.AudioSchema = zod_1.default
2169
+ .object({
2170
+ type: zod_1.default.literal("audio"),
2171
+ description: zod_1.default
2172
+ .string()
2173
+ .optional()
2174
+ .nullable()
2175
+ .describe("The description of the audio input."),
2176
+ })
2177
+ .describe("An audio input schema.");
2178
+ InputSchema.VideoSchema = zod_1.default
2179
+ .object({
2180
+ type: zod_1.default.literal("video"),
2181
+ description: zod_1.default
2182
+ .string()
2183
+ .optional()
2184
+ .nullable()
2185
+ .describe("The description of the video input."),
2186
+ })
2187
+ .describe("A video input schema.");
2188
+ InputSchema.FileSchema = zod_1.default
2189
+ .object({
2190
+ type: zod_1.default.literal("file"),
2191
+ description: zod_1.default
2192
+ .string()
2193
+ .optional()
2194
+ .nullable()
2195
+ .describe("The description of the file input."),
2196
+ })
2197
+ .describe("A file input schema.");
2198
+ })(InputSchema = Function_1.InputSchema || (Function_1.InputSchema = {}));
2199
+ Function_1.InputSchema_ = zod_1.default
2200
+ .lazy(() => zod_1.default.union([
2201
+ Message.RichContent.PartSchema,
2202
+ zod_1.default.record(zod_1.default.string(), Function_1.InputSchema_),
2203
+ zod_1.default.array(Function_1.InputSchema_),
2204
+ zod_1.default.string(),
2205
+ zod_1.default.number(),
2206
+ zod_1.default.boolean(),
2207
+ ]))
2208
+ .describe("The input provided to the function.");
2209
+ Function_1.InputExpressionSchema = zod_1.default.lazy(() => zod_1.default
2210
+ .union([
2211
+ Message.RichContent.PartSchema,
2212
+ zod_1.default.record(zod_1.default.string(), Function_1.InputExpressionSchema),
2213
+ zod_1.default.array(Function_1.InputExpressionSchema),
2214
+ zod_1.default.string(),
2215
+ zod_1.default.number(),
2216
+ zod_1.default.boolean(),
2217
+ exports.ExpressionSchema.describe("An expression which evaluates to an input."),
2218
+ ])
2219
+ .describe(Function_1.InputSchema_.description));
2220
+ Function_1.InputMapsExpressionSchema = zod_1.default
2221
+ .union([
2222
+ exports.ExpressionSchema.describe("An expression which evaluates to a 2D array of Inputs."),
2223
+ zod_1.default
2224
+ .array(exports.ExpressionSchema.describe("An expression which evaluates to a 1D array of Inputs."))
2225
+ .describe("A list of expressions which each evaluate to a 1D array of Inputs."),
2226
+ ])
2227
+ .describe("An expression or list of expressions which evaluate to a 2D array of Inputs. Each sub-array will be fed into Tasks which specify an index of this input map.");
2228
+ Function_1.TaskExpressionSchema = zod_1.default
2229
+ .discriminatedUnion("type", [
2230
+ TaskExpression.ScalarFunctionSchema,
2231
+ TaskExpression.VectorFunctionSchema,
2232
+ TaskExpression.VectorCompletionSchema,
2233
+ ])
2234
+ .describe("A task to be executed as part of the function. Will first be compiled using the parent function's input. May be skipped or mapped.");
2235
+ let TaskExpression;
2236
+ (function (TaskExpression) {
2237
+ TaskExpression.SkipSchema = exports.ExpressionSchema.describe("An expression which evaluates to a boolean indicating whether to skip this task.");
2238
+ TaskExpression.MapSchema = zod_1.default
2239
+ .uint32()
2240
+ .describe("If present, indicates that this task should be ran once for each entry in the specified input map (input map is a 2D array indexed by this value).");
2241
+ TaskExpression.ScalarFunctionSchema = zod_1.default
2242
+ .object({
2243
+ type: zod_1.default.literal("scalar.function"),
2244
+ author: zod_1.default
2245
+ .string()
2246
+ .describe("The author of the remote published scalar function."),
2247
+ id: zod_1.default
2248
+ .string()
2249
+ .describe("The unique identifier of the remote published scalar function."),
2250
+ version: zod_1.default
2251
+ .uint32()
2252
+ .describe("The version of the remote published scalar function."),
2253
+ skip: TaskExpression.SkipSchema.optional().nullable(),
2254
+ map: TaskExpression.MapSchema.optional().nullable(),
2255
+ input: Function_1.InputExpressionSchema,
2256
+ })
2257
+ .describe("A remote published scalar function task.");
2258
+ TaskExpression.VectorFunctionSchema = zod_1.default
2259
+ .object({
2260
+ type: zod_1.default.literal("vector.function"),
2261
+ author: zod_1.default
2262
+ .string()
2263
+ .describe("The author of the remote published vector function."),
2264
+ id: zod_1.default
2265
+ .string()
2266
+ .describe("The unique identifier of the remote published vector function."),
2267
+ version: zod_1.default
2268
+ .uint32()
2269
+ .describe("The version of the remote published vector function."),
2270
+ skip: TaskExpression.SkipSchema.optional().nullable(),
2271
+ map: TaskExpression.MapSchema.optional().nullable(),
2272
+ input: Function_1.InputExpressionSchema,
2273
+ })
2274
+ .describe("A remote published vector function task.");
2275
+ TaskExpression.VectorCompletionSchema = zod_1.default
2276
+ .object({
2277
+ type: zod_1.default.literal("vector.completion"),
2278
+ skip: TaskExpression.SkipSchema.optional().nullable(),
2279
+ map: TaskExpression.MapSchema.optional().nullable(),
2280
+ messages: exports.MessagesExpressionSchema,
2281
+ tools: exports.ToolsExpressionSchema.optional()
2282
+ .nullable()
2283
+ .describe(`${exports.ToolsExpressionSchema.description} These are readonly and will only be useful for explaining prior tool calls or otherwise influencing behavior.`),
2284
+ responses: exports.VectorResponsesExpressionSchema,
2285
+ })
2286
+ .describe("A vector completion task.");
2287
+ })(TaskExpression = Function_1.TaskExpression || (Function_1.TaskExpression = {}));
2288
+ Function_1.TaskExpressionsSchema = zod_1.default
2289
+ .array(Function_1.TaskExpressionSchema)
2290
+ .describe("The list of tasks to be executed as part of the function.");
2291
+ Function_1.ScalarSchema = zod_1.default
2292
+ .object({
2293
+ type: zod_1.default.literal("scalar.function"),
2294
+ author: zod_1.default.string().describe("The author of the scalar function."),
2295
+ id: zod_1.default.string().describe("The unique identifier of the scalar function."),
2296
+ version: zod_1.default.uint32().describe("The version of the scalar function."),
2297
+ description: zod_1.default
2298
+ .string()
2299
+ .describe("The description of the scalar function."),
2300
+ changelog: zod_1.default
2301
+ .string()
2302
+ .optional()
2303
+ .nullable()
2304
+ .describe("When present, describes changes from the previous version or versions."),
2305
+ input_schema: Function_1.InputSchemaSchema,
2306
+ input_maps: Function_1.InputMapsExpressionSchema.optional().nullable(),
2307
+ tasks: Function_1.TaskExpressionsSchema,
2308
+ output: exports.ExpressionSchema.describe("An expression which evaluates to a single number. This is the output of the scalar function. Will be provided with the outputs of all tasks."),
2309
+ })
2310
+ .describe("A scalar function.");
2311
+ Function_1.VectorSchema = zod_1.default
2312
+ .object({
2313
+ type: zod_1.default.literal("vector.function"),
2314
+ author: zod_1.default.string().describe("The author of the vector function."),
2315
+ id: zod_1.default.string().describe("The unique identifier of the vector function."),
2316
+ version: zod_1.default.uint32().describe("The version of the vector function."),
2317
+ description: zod_1.default
2318
+ .string()
2319
+ .describe("The description of the vector function."),
2320
+ changelog: zod_1.default
2321
+ .string()
2322
+ .optional()
2323
+ .nullable()
2324
+ .describe("When present, describes changes from the previous version or versions."),
2325
+ input_schema: Function_1.InputSchemaSchema,
2326
+ input_maps: Function_1.InputMapsExpressionSchema.optional().nullable(),
2327
+ tasks: Function_1.TaskExpressionsSchema,
2328
+ output: exports.ExpressionSchema.describe("An expressions which evaluates to an array of numbers. This is the output of the vector function. Will be provided with the outputs of all tasks."),
2329
+ output_length: zod_1.default
2330
+ .union([
2331
+ zod_1.default.uint32().describe("The fixed length of the output vector."),
2332
+ exports.ExpressionSchema.describe("An expression which evaluates to the length of the output vector. Will only be provided with the function input. The output length must be determinable from the input alone."),
2333
+ ])
2334
+ .describe("The length of the output vector."),
2335
+ })
2336
+ .describe("A vector function.");
2337
+ let Executions;
2338
+ (function (Executions) {
2339
+ let Request;
2340
+ (function (Request) {
2341
+ Request.FunctionExecutionParamsBaseSchema = zod_1.default
2342
+ .object({
2343
+ retry_token: zod_1.default
2344
+ .string()
2345
+ .optional()
2346
+ .nullable()
2347
+ .describe("The retry token provided by a previous incomplete or failed function execution."),
2348
+ input: Function_1.InputSchema_,
2349
+ provider: Chat.Completions.Request.ProviderSchema.optional().nullable(),
2350
+ seed: Chat.Completions.Request.SeedSchema.optional().nullable(),
2351
+ backoff_max_elapsed_time: Chat.Completions.Request.BackoffMaxElapsedTimeSchema.optional().nullable(),
2352
+ first_chunk_timeout: Chat.Completions.Request.FirstChunkTimeoutSchema.optional().nullable(),
2353
+ other_chunk_timeout: Chat.Completions.Request.OtherChunkTimeoutSchema.optional().nullable(),
2354
+ })
2355
+ .describe("Base parameters for executing a function.");
2356
+ // Execute Inline Function
2357
+ Request.FunctionExecutionParamsExecuteInlineBaseSchema = Request.FunctionExecutionParamsBaseSchema.extend({
2358
+ function: exports.FunctionSchema,
2359
+ profile: Function_1.FunctionProfileVersionOptionalSchema,
2360
+ }).describe("Base parameters for executing an inline function.");
2361
+ Request.FunctionExecutionParamsExecuteInlineStreamingSchema = Request.FunctionExecutionParamsExecuteInlineBaseSchema.extend({
2362
+ stream: Chat.Completions.Request.StreamTrueSchema,
2363
+ }).describe("Parameters for executing an inline function and streaming the response.");
2364
+ Request.FunctionExecutionParamsExecuteInlineNonStreamingSchema = Request.FunctionExecutionParamsExecuteInlineBaseSchema.extend({
2365
+ stream: Chat.Completions.Request.StreamFalseSchema.optional().nullable(),
2366
+ }).describe("Parameters for executing an inline function with a unary response.");
2367
+ Request.FunctionExecutionParamsExecuteInlineSchema = zod_1.default
2368
+ .union([
2369
+ Request.FunctionExecutionParamsExecuteInlineStreamingSchema,
2370
+ Request.FunctionExecutionParamsExecuteInlineNonStreamingSchema,
2371
+ ])
2372
+ .describe("Parameters for executing an inline function.");
2373
+ // Execute Published Function
2374
+ Request.FunctionExecutionParamsExecuteBaseSchema = Request.FunctionExecutionParamsBaseSchema.extend({
2375
+ profile: Function_1.FunctionProfileVersionOptionalSchema.optional().nullable(),
2376
+ }).describe("Base parameters for executing a remote published function.");
2377
+ Request.FunctionExecutionParamsExecuteStreamingSchema = Request.FunctionExecutionParamsExecuteBaseSchema.extend({
2378
+ stream: Chat.Completions.Request.StreamTrueSchema,
2379
+ }).describe("Parameters for executing a remote published function and streaming the response.");
2380
+ Request.FunctionExecutionParamsExecuteNonStreamingSchema = Request.FunctionExecutionParamsExecuteBaseSchema.extend({
2381
+ stream: Chat.Completions.Request.StreamFalseSchema.optional().nullable(),
2382
+ }).describe("Parameters for executing a remote published function with a unary response.");
2383
+ Request.FunctionExecutionParamsExecuteSchema = zod_1.default
2384
+ .union([
2385
+ Request.FunctionExecutionParamsExecuteStreamingSchema,
2386
+ Request.FunctionExecutionParamsExecuteNonStreamingSchema,
2387
+ ])
2388
+ .describe("Parameters for executing a remote published function.");
2389
+ // Publish Scalar Function
2390
+ Request.FunctionExecutionParamsPublishScalarFunctionBaseSchema = Request.FunctionExecutionParamsBaseSchema.extend({
2391
+ function: Function_1.ScalarSchema,
2392
+ publish_function: zod_1.default
2393
+ .object({
2394
+ description: zod_1.default
2395
+ .string()
2396
+ .describe("The description of the published scalar function."),
2397
+ changelog: zod_1.default
2398
+ .string()
2399
+ .optional()
2400
+ .nullable()
2401
+ .describe("When present, describes changes from the previous version or versions."),
2402
+ input_schema: Function_1.InputSchemaSchema,
2403
+ })
2404
+ .describe("Details about the scalar function to be published."),
2405
+ profile: Function_1.FunctionProfileVersionRequiredSchema,
2406
+ publish_profile: zod_1.default
2407
+ .object({
2408
+ id: zod_1.default
2409
+ .literal("default")
2410
+ .describe('The identifier of the profile to publish. Must be "default" when publishing a function.'),
2411
+ version: zod_1.default
2412
+ .uint32()
2413
+ .describe("The version of the profile to publish. Must match the function's version."),
2414
+ description: zod_1.default
2415
+ .string()
2416
+ .describe("The description of the published profile."),
2417
+ changelog: zod_1.default
2418
+ .string()
2419
+ .optional()
2420
+ .nullable()
2421
+ .describe("When present, describes changes from the previous version or versions."),
2422
+ })
2423
+ .describe("Details about the profile to be published."),
2424
+ }).describe("Base parameters for executing and publishing an inline scalar function.");
2425
+ Request.FunctionExecutionParamsPublishScalarFunctionStreamingSchema = Request.FunctionExecutionParamsPublishScalarFunctionBaseSchema.extend({
2426
+ stream: Chat.Completions.Request.StreamTrueSchema,
2427
+ }).describe("Parameters for executing and publishing an inline scalar function and streaming the response.");
2428
+ Request.FunctionExecutionParamsPublishScalarFunctionNonStreamingSchema = Request.FunctionExecutionParamsPublishScalarFunctionBaseSchema.extend({
2429
+ stream: Chat.Completions.Request.StreamFalseSchema.optional().nullable(),
2430
+ }).describe("Parameters for executing and publishing an inline scalar function with a unary response.");
2431
+ Request.FunctionExecutionParamsPublishScalarFunctionSchema = zod_1.default
2432
+ .union([
2433
+ Request.FunctionExecutionParamsPublishScalarFunctionStreamingSchema,
2434
+ Request.FunctionExecutionParamsPublishScalarFunctionNonStreamingSchema,
2435
+ ])
2436
+ .describe("Parameters for executing and publishing an inline scalar function.");
2437
+ // Publish Vector Function
2438
+ Request.FunctionExecutionParamsPublishVectorFunctionBaseSchema = Request.FunctionExecutionParamsBaseSchema.extend({
2439
+ function: Function_1.VectorSchema,
2440
+ publish_function: zod_1.default
2441
+ .object({
2442
+ description: zod_1.default
2443
+ .string()
2444
+ .describe("The description of the published vector function."),
2445
+ changelog: zod_1.default
2446
+ .string()
2447
+ .optional()
2448
+ .nullable()
2449
+ .describe("When present, describes changes from the previous version or versions."),
2450
+ input_schema: Function_1.InputSchemaSchema,
2451
+ output_length: zod_1.default
2452
+ .union([
2453
+ zod_1.default.uint32().describe("The fixed length of the output vector."),
2454
+ exports.ExpressionSchema.describe("An expression which evaluates to the length of the output vector. Will only be provided with the function input. The output length must be determinable from the input alone."),
2455
+ ])
2456
+ .describe("The length of the output vector."),
2457
+ })
2458
+ .describe("Details about the vector function to be published."),
2459
+ profile: Function_1.FunctionProfileVersionRequiredSchema,
2460
+ publish_profile: zod_1.default
2461
+ .object({
2462
+ id: zod_1.default
2463
+ .literal("default")
2464
+ .describe('The identifier of the profile to publish. Must be "default" when publishing a function.'),
2465
+ version: zod_1.default
2466
+ .uint32()
2467
+ .describe("The version of the profile to publish. Must match the function's version."),
2468
+ description: zod_1.default
2469
+ .string()
2470
+ .describe("The description of the published profile."),
2471
+ changelog: zod_1.default
2472
+ .string()
2473
+ .optional()
2474
+ .nullable()
2475
+ .describe("When present, describes changes from the previous version or versions."),
2476
+ })
2477
+ .describe("Details about the profile to be published."),
2478
+ }).describe("Base parameters for executing and publishing an inline vector function.");
2479
+ Request.FunctionExecutionParamsPublishVectorFunctionStreamingSchema = Request.FunctionExecutionParamsPublishVectorFunctionBaseSchema.extend({
2480
+ stream: Chat.Completions.Request.StreamTrueSchema,
2481
+ }).describe("Parameters for executing and publishing an inline vector function and streaming the response.");
2482
+ Request.FunctionExecutionParamsPublishVectorFunctionNonStreamingSchema = Request.FunctionExecutionParamsPublishVectorFunctionBaseSchema.extend({
2483
+ stream: Chat.Completions.Request.StreamFalseSchema.optional().nullable(),
2484
+ }).describe("Parameters for executing and publishing an inline vector function with a unary response.");
2485
+ Request.FunctionExecutionParamsPublishVectorFunctionSchema = zod_1.default
2486
+ .union([
2487
+ Request.FunctionExecutionParamsPublishVectorFunctionStreamingSchema,
2488
+ Request.FunctionExecutionParamsPublishVectorFunctionNonStreamingSchema,
2489
+ ])
2490
+ .describe("Parameters for executing and publishing an inline vector function.");
2491
+ // Publish Function
2492
+ Request.FunctionExecutionParamsPublishFunctionStreamingSchema = zod_1.default
2493
+ .union([
2494
+ Request.FunctionExecutionParamsPublishScalarFunctionStreamingSchema,
2495
+ Request.FunctionExecutionParamsPublishVectorFunctionStreamingSchema,
2496
+ ])
2497
+ .describe("Parameters for executing and publishing an inline function and streaming the response.");
2498
+ Request.FunctionExecutionParamsPublishFunctionNonStreamingSchema = zod_1.default
2499
+ .union([
2500
+ Request.FunctionExecutionParamsPublishScalarFunctionNonStreamingSchema,
2501
+ Request.FunctionExecutionParamsPublishVectorFunctionNonStreamingSchema,
2502
+ ])
2503
+ .describe("Parameters for executing and publishing an inline function with a unary response.");
2504
+ Request.FunctionExecutionParamsPublishFunctionSchema = zod_1.default
2505
+ .union([
2506
+ Request.FunctionExecutionParamsPublishScalarFunctionSchema,
2507
+ Request.FunctionExecutionParamsPublishVectorFunctionSchema,
2508
+ ])
2509
+ .describe("Parameters for executing and publishing an inline function.");
2510
+ // Publish Profile
2511
+ Request.FunctionExecutionParamsPublishProfileBaseSchema = Request.FunctionExecutionParamsBaseSchema.extend({
2512
+ profile: zod_1.default
2513
+ .array(Function_1.ProfileVersionRequiredSchema)
2514
+ .describe("The profile to publish."),
2515
+ publish_profile: zod_1.default
2516
+ .object({
2517
+ id: zod_1.default
2518
+ .string()
2519
+ .describe("The unique identifier of the profile to publish."),
2520
+ version: zod_1.default
2521
+ .uint32()
2522
+ .describe("The version of the profile to publish."),
2523
+ description: zod_1.default
2524
+ .string()
2525
+ .describe("The description of the published profile."),
2526
+ changelog: zod_1.default
2527
+ .string()
2528
+ .optional()
2529
+ .nullable()
2530
+ .describe("When present, describes changes from the previous version or versions."),
2531
+ })
2532
+ .describe("Details about the profile to be published."),
2533
+ }).describe("Base parameters for executing a remote published function and publishing a profile.");
2534
+ Request.FunctionExecutionParamsPublishProfileStreamingSchema = Request.FunctionExecutionParamsPublishProfileBaseSchema.extend({
2535
+ stream: Chat.Completions.Request.StreamTrueSchema,
2536
+ }).describe("Parameters for executing a remote published function, publishing a profile, and streaming the response.");
2537
+ Request.FunctionExecutionParamsPublishProfileNonStreamingSchema = Request.FunctionExecutionParamsPublishProfileBaseSchema.extend({
2538
+ stream: Chat.Completions.Request.StreamFalseSchema.optional().nullable(),
2539
+ }).describe("Parameters for executing a remote published function and publishing a profile with a unary response.");
2540
+ Request.FunctionExecutionParamsPublishProfileSchema = zod_1.default
2541
+ .union([
2542
+ Request.FunctionExecutionParamsPublishProfileStreamingSchema,
2543
+ Request.FunctionExecutionParamsPublishProfileNonStreamingSchema,
2544
+ ])
2545
+ .describe("Parameters for executing a remote published function and publishing a profile.");
2546
+ })(Request = Executions.Request || (Executions.Request = {}));
544
2547
  let Response;
545
2548
  (function (Response) {
2549
+ let Task;
2550
+ (function (Task) {
2551
+ Task.IndexSchema = zod_1.default
2552
+ .uint32()
2553
+ .describe("The index of the task in the sequence of tasks.");
2554
+ Task.TaskIndexSchema = zod_1.default
2555
+ .uint32()
2556
+ .describe("The index of the task amongst all mapped and non-skipped compiled tasks. Used internally.");
2557
+ Task.TaskPathSchema = zod_1.default
2558
+ .array(zod_1.default.uint32())
2559
+ .describe("The path of this task which may be used to navigate which nested task this is amongst the root functions tasks and sub-tasks.");
2560
+ })(Task = Response.Task || (Response.Task = {}));
546
2561
  let Streaming;
547
2562
  (function (Streaming) {
548
- let ChatCompletionChunk;
549
- (function (ChatCompletionChunk) {
2563
+ Streaming.TaskChunkSchema = zod_1.default
2564
+ .union([TaskChunk.FunctionSchema, TaskChunk.VectorCompletionSchema])
2565
+ .describe("A chunk of a task execution.");
2566
+ let TaskChunk;
2567
+ (function (TaskChunk) {
2568
+ function merged(a, b) {
2569
+ if ("scores" in a) {
2570
+ return VectorCompletion.merged(a, b);
2571
+ }
2572
+ else {
2573
+ return Function.merged(a, b);
2574
+ }
2575
+ }
2576
+ TaskChunk.merged = merged;
2577
+ function mergedList(a, b) {
2578
+ let merged = undefined;
2579
+ for (const chunk of b) {
2580
+ const existingIndex = a.findIndex(({ index }) => index === chunk.index);
2581
+ if (existingIndex === -1) {
2582
+ if (merged === undefined) {
2583
+ merged = [...a, chunk];
2584
+ }
2585
+ else {
2586
+ merged.push(chunk);
2587
+ }
2588
+ }
2589
+ else {
2590
+ const [mergedChunk, chunkChanged] = TaskChunk.merged(a[existingIndex], chunk);
2591
+ if (chunkChanged) {
2592
+ if (merged === undefined) {
2593
+ merged = [...a];
2594
+ }
2595
+ merged[existingIndex] = mergedChunk;
2596
+ }
2597
+ }
2598
+ }
2599
+ return merged ? [merged, true] : [a, false];
2600
+ }
2601
+ TaskChunk.mergedList = mergedList;
2602
+ TaskChunk.FunctionSchema = zod_1.default
2603
+ .lazy(() => Streaming.FunctionExecutionChunkSchema.extend({
2604
+ index: Task.IndexSchema,
2605
+ task_index: Task.TaskIndexSchema,
2606
+ task_path: Task.TaskPathSchema,
2607
+ }))
2608
+ .describe("A chunk of a function execution task.");
2609
+ let Function;
2610
+ (function (Function) {
2611
+ function merged(a, b) {
2612
+ const index = a.index;
2613
+ const task_index = a.task_index;
2614
+ const task_path = a.task_path;
2615
+ const [base, baseChanged] = FunctionExecutionChunk.merged(a, b);
2616
+ if (baseChanged) {
2617
+ return [
2618
+ Object.assign({ index,
2619
+ task_index,
2620
+ task_path }, base),
2621
+ true,
2622
+ ];
2623
+ }
2624
+ else {
2625
+ return [a, false];
2626
+ }
2627
+ }
2628
+ Function.merged = merged;
2629
+ })(Function = TaskChunk.Function || (TaskChunk.Function = {}));
2630
+ TaskChunk.VectorCompletionSchema = Vector.Completions.Response.Streaming.VectorCompletionChunkSchema.extend({
2631
+ index: Task.IndexSchema,
2632
+ task_index: Task.TaskIndexSchema,
2633
+ task_path: Task.TaskPathSchema,
2634
+ error: exports.ObjectiveAIErrorSchema.optional().describe("When present, indicates that an error occurred during the vector completion task."),
2635
+ }).describe("A chunk of a vector completion task.");
2636
+ let VectorCompletion;
2637
+ (function (VectorCompletion) {
2638
+ function merged(a, b) {
2639
+ const index = a.index;
2640
+ const task_index = a.task_index;
2641
+ const task_path = a.task_path;
2642
+ const [base, baseChanged] = Vector.Completions.Response.Streaming.VectorCompletionChunk.merged(a, b);
2643
+ const [error, errorChanged] = merge(a.error, b.error);
2644
+ if (baseChanged || errorChanged) {
2645
+ return [
2646
+ Object.assign(Object.assign({ index,
2647
+ task_index,
2648
+ task_path }, base), (error !== undefined ? { error } : {})),
2649
+ true,
2650
+ ];
2651
+ }
2652
+ else {
2653
+ return [a, false];
2654
+ }
2655
+ }
2656
+ VectorCompletion.merged = merged;
2657
+ })(VectorCompletion = TaskChunk.VectorCompletion || (TaskChunk.VectorCompletion = {}));
2658
+ })(TaskChunk = Streaming.TaskChunk || (Streaming.TaskChunk = {}));
2659
+ Streaming.FunctionExecutionChunkSchema = zod_1.default
2660
+ .object({
2661
+ id: zod_1.default
2662
+ .string()
2663
+ .describe("The unique identifier of the function execution."),
2664
+ tasks: zod_1.default
2665
+ .array(Streaming.TaskChunkSchema)
2666
+ .describe("The tasks executed as part of the function execution."),
2667
+ tasks_errors: zod_1.default
2668
+ .boolean()
2669
+ .optional()
2670
+ .describe("When true, indicates that one or more tasks encountered errors during execution."),
2671
+ output: zod_1.default
2672
+ .union([
2673
+ zod_1.default
2674
+ .number()
2675
+ .describe("The scalar output of the function execution."),
2676
+ zod_1.default
2677
+ .array(zod_1.default.number())
2678
+ .describe("The vector output of the function execution."),
2679
+ exports.JsonValueSchema.describe("The erroneous output of the function execution."),
2680
+ ])
2681
+ .optional()
2682
+ .describe("The output of the function execution."),
2683
+ error: exports.ObjectiveAIErrorSchema.optional().describe("When present, indicates that an error occurred during the function execution."),
2684
+ retry_token: zod_1.default
2685
+ .string()
2686
+ .optional()
2687
+ .describe("A token which may be used to retry the function execution."),
2688
+ function_published: zod_1.default
2689
+ .boolean()
2690
+ .optional()
2691
+ .describe("When true, indicates that a function was published as part of this execution."),
2692
+ profile_published: zod_1.default
2693
+ .boolean()
2694
+ .optional()
2695
+ .describe("When true, indicates that a profile was published as part of this execution."),
2696
+ created: zod_1.default
2697
+ .uint32()
2698
+ .describe("The UNIX timestamp (in seconds) when the function execution chunk was created."),
2699
+ function: zod_1.default
2700
+ .string()
2701
+ .nullable()
2702
+ .describe("The unique identifier of the function being executed."),
2703
+ profile: zod_1.default
2704
+ .string()
2705
+ .nullable()
2706
+ .describe("The unique identifier of the profile being used."),
2707
+ object: zod_1.default
2708
+ .enum([
2709
+ "scalar.function.execution.chunk",
2710
+ "vector.function.execution.chunk",
2711
+ ])
2712
+ .describe("The object type."),
2713
+ usage: Vector.Completions.Response.UsageSchema.optional(),
2714
+ })
2715
+ .describe("A chunk of a function execution.");
2716
+ let FunctionExecutionChunk;
2717
+ (function (FunctionExecutionChunk) {
550
2718
  function merged(a, b) {
551
2719
  const id = a.id;
552
- const [choices, choicesChanged] = Choice.mergedList(a.choices, b.choices);
2720
+ const [tasks, tasksChanged] = TaskChunk.mergedList(a.tasks, b.tasks);
2721
+ const [tasks_errors, tasks_errorsChanged] = merge(a.tasks_errors, b.tasks_errors);
2722
+ const [output, outputChanged] = merge(a.output, b.output);
2723
+ const [error, errorChanged] = merge(a.error, b.error);
2724
+ const [retry_token, retry_tokenChanged] = merge(a.retry_token, b.retry_token);
2725
+ const [function_published, function_publishedChanged] = merge(a.function_published, b.function_published);
2726
+ const [profile_published, profile_publishedChanged] = merge(a.profile_published, b.profile_published);
553
2727
  const created = a.created;
554
- const model = a.model;
2728
+ const function_ = a.function;
2729
+ const profile = a.profile;
555
2730
  const object = a.object;
556
- const [usage, usageChanged] = merge(a.usage, b.usage, Chat.Completions.Response.Usage.merged);
557
- if (choicesChanged || usageChanged) {
2731
+ const [usage, usageChanged] = merge(a.usage, b.usage);
2732
+ if (tasksChanged ||
2733
+ tasks_errorsChanged ||
2734
+ outputChanged ||
2735
+ errorChanged ||
2736
+ retry_tokenChanged ||
2737
+ function_publishedChanged ||
2738
+ profile_publishedChanged ||
2739
+ usageChanged) {
558
2740
  return [
559
- Object.assign({ id,
560
- choices,
561
- created,
562
- model,
563
- object }, (usage !== undefined ? { usage } : {})),
2741
+ Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ id,
2742
+ tasks }, (tasks_errors !== undefined ? { tasks_errors } : {})), (output !== undefined ? { output } : {})), (error !== undefined ? { error } : {})), (retry_token !== undefined ? { retry_token } : {})), (function_published !== undefined
2743
+ ? { function_published }
2744
+ : {})), (profile_published !== undefined
2745
+ ? { profile_published }
2746
+ : {})), { created, function: function_, profile,
2747
+ object }), (usage !== undefined ? { usage } : {})),
564
2748
  true,
565
2749
  ];
566
2750
  }
@@ -568,32 +2752,216 @@ var Multichat;
568
2752
  return [a, false];
569
2753
  }
570
2754
  }
571
- ChatCompletionChunk.merged = merged;
572
- })(ChatCompletionChunk = Streaming.ChatCompletionChunk || (Streaming.ChatCompletionChunk = {}));
573
- let Choice;
574
- (function (Choice) {
2755
+ FunctionExecutionChunk.merged = merged;
2756
+ })(FunctionExecutionChunk = Streaming.FunctionExecutionChunk || (Streaming.FunctionExecutionChunk = {}));
2757
+ })(Streaming = Response.Streaming || (Response.Streaming = {}));
2758
+ let Unary;
2759
+ (function (Unary) {
2760
+ Unary.TaskSchema = zod_1.default
2761
+ .union([Task.FunctionSchema, Task.VectorCompletionSchema])
2762
+ .describe("A task execution.");
2763
+ let Task;
2764
+ (function (Task) {
2765
+ Task.FunctionSchema = zod_1.default
2766
+ .lazy(() => Unary.FunctionExecutionSchema.extend({
2767
+ index: Response.Task.IndexSchema,
2768
+ task_index: Response.Task.TaskIndexSchema,
2769
+ task_path: Response.Task.TaskPathSchema,
2770
+ }))
2771
+ .describe("A chunk of a function execution task.");
2772
+ Task.VectorCompletionSchema = Vector.Completions.Response.Unary.VectorCompletionSchema.extend({
2773
+ index: Response.Task.IndexSchema,
2774
+ task_index: Response.Task.TaskIndexSchema,
2775
+ task_path: Response.Task.TaskPathSchema,
2776
+ error: exports.ObjectiveAIErrorSchema.nullable().describe("When non-null, indicates that an error occurred during the vector completion task."),
2777
+ }).describe("A vector completion task.");
2778
+ })(Task = Unary.Task || (Unary.Task = {}));
2779
+ Unary.FunctionExecutionSchema = zod_1.default
2780
+ .object({
2781
+ id: zod_1.default
2782
+ .string()
2783
+ .describe("The unique identifier of the function execution."),
2784
+ tasks: zod_1.default
2785
+ .array(Unary.TaskSchema)
2786
+ .describe("The tasks executed as part of the function execution."),
2787
+ tasks_errors: zod_1.default
2788
+ .boolean()
2789
+ .describe("When true, indicates that one or more tasks encountered errors during execution."),
2790
+ output: zod_1.default
2791
+ .union([
2792
+ zod_1.default
2793
+ .number()
2794
+ .describe("The scalar output of the function execution."),
2795
+ zod_1.default
2796
+ .array(zod_1.default.number())
2797
+ .describe("The vector output of the function execution."),
2798
+ exports.JsonValueSchema.describe("The erroneous output of the function execution."),
2799
+ ])
2800
+ .describe("The output of the function execution."),
2801
+ error: exports.ObjectiveAIErrorSchema.nullable().describe("When non-null, indicates that an error occurred during the function execution."),
2802
+ retry_token: zod_1.default
2803
+ .string()
2804
+ .nullable()
2805
+ .describe("A token which may be used to retry the function execution."),
2806
+ function_published: zod_1.default
2807
+ .boolean()
2808
+ .optional()
2809
+ .describe("When true, indicates that a function was published as part of this execution."),
2810
+ profile_published: zod_1.default
2811
+ .boolean()
2812
+ .optional()
2813
+ .describe("When true, indicates that a profile was published as part of this execution."),
2814
+ created: zod_1.default
2815
+ .uint32()
2816
+ .describe("The UNIX timestamp (in seconds) when the function execution chunk was created."),
2817
+ function: zod_1.default
2818
+ .string()
2819
+ .nullable()
2820
+ .describe("The unique identifier of the function being executed."),
2821
+ profile: zod_1.default
2822
+ .string()
2823
+ .nullable()
2824
+ .describe("The unique identifier of the profile being used."),
2825
+ object: zod_1.default
2826
+ .enum(["scalar.function.execution", "vector.function.execution"])
2827
+ .describe("The object type."),
2828
+ usage: Vector.Completions.Response.UsageSchema,
2829
+ })
2830
+ .describe("A function execution.");
2831
+ })(Unary = Response.Unary || (Response.Unary = {}));
2832
+ })(Response = Executions.Response || (Executions.Response = {}));
2833
+ })(Executions = Function_1.Executions || (Function_1.Executions = {}));
2834
+ let ComputeProfile;
2835
+ (function (ComputeProfile) {
2836
+ let Request;
2837
+ (function (Request) {
2838
+ Request.DatasetItemSchema = zod_1.default
2839
+ .object({
2840
+ input: Function_1.InputSchema_,
2841
+ target: DatasetItem.TargetSchema,
2842
+ })
2843
+ .describe("A Function input and its corresponding target output.");
2844
+ let DatasetItem;
2845
+ (function (DatasetItem) {
2846
+ DatasetItem.TargetSchema = zod_1.default
2847
+ .union([
2848
+ Target.ScalarSchema,
2849
+ Target.VectorSchema,
2850
+ Target.VectorWinnerSchema,
2851
+ ])
2852
+ .describe("The target output for a given function input.");
2853
+ let Target;
2854
+ (function (Target) {
2855
+ Target.ScalarSchema = zod_1.default
2856
+ .object({
2857
+ type: zod_1.default.literal("scalar"),
2858
+ value: zod_1.default.number(),
2859
+ })
2860
+ .describe("A scalar target output. The desired output is this exact scalar.");
2861
+ Target.VectorSchema = zod_1.default
2862
+ .object({
2863
+ type: zod_1.default.literal("vector"),
2864
+ value: zod_1.default.array(zod_1.default.number()),
2865
+ })
2866
+ .describe("A vector target output. The desired output is this exact vector.");
2867
+ Target.VectorWinnerSchema = zod_1.default
2868
+ .object({
2869
+ type: zod_1.default.literal("vector_winner"),
2870
+ value: zod_1.default.uint32(),
2871
+ })
2872
+ .describe("A vector winner target output. The desired output is a vector where the highest value is at the specified index.");
2873
+ })(Target = DatasetItem.Target || (DatasetItem.Target = {}));
2874
+ })(DatasetItem = Request.DatasetItem || (Request.DatasetItem = {}));
2875
+ Request.FunctionComputeProfileParamsBaseSchema = zod_1.default
2876
+ .object({
2877
+ retry_token: zod_1.default
2878
+ .string()
2879
+ .optional()
2880
+ .nullable()
2881
+ .describe("The retry token provided by a previous incomplete or failed profile computation."),
2882
+ max_retries: zod_1.default
2883
+ .uint32()
2884
+ .optional()
2885
+ .nullable()
2886
+ .describe("The maximum number of retries to attempt when a function execution fails during profile computation."),
2887
+ n: zod_1.default
2888
+ .uint32()
2889
+ .describe("The number of function executions to perform per dataset item. Generally speaking, higher N values increase the quality of the computed profile."),
2890
+ dataset: zod_1.default
2891
+ .array(Request.DatasetItemSchema)
2892
+ .describe("The dataset of input and target output pairs to use for computing the profile."),
2893
+ ensemble: Vector.Completions.Request.EnsembleSchema,
2894
+ provider: Chat.Completions.Request.ProviderSchema.optional().nullable(),
2895
+ seed: Chat.Completions.Request.SeedSchema.optional().nullable(),
2896
+ backoff_max_elapsed_time: Chat.Completions.Request.BackoffMaxElapsedTimeSchema.optional().nullable(),
2897
+ first_chunk_timeout: Chat.Completions.Request.FirstChunkTimeoutSchema.optional().nullable(),
2898
+ other_chunk_timeout: Chat.Completions.Request.OtherChunkTimeoutSchema.optional().nullable(),
2899
+ })
2900
+ .describe("Base parameters for computing a function profile.");
2901
+ Request.FunctionComputeProfileParamsStreamingSchema = Request.FunctionComputeProfileParamsBaseSchema.extend({
2902
+ stream: Chat.Completions.Request.StreamTrueSchema,
2903
+ }).describe("Parameters for computing a function profile and streaming the response.");
2904
+ Request.FunctionComputeProfileParamsNonStreamingSchema = Request.FunctionComputeProfileParamsBaseSchema.extend({
2905
+ stream: Chat.Completions.Request.StreamFalseSchema.optional().nullable(),
2906
+ }).describe("Parameters for computing a function profile with a unary response.");
2907
+ Request.FunctionComputeProfileParamsSchema = zod_1.default
2908
+ .union([
2909
+ Request.FunctionComputeProfileParamsStreamingSchema,
2910
+ Request.FunctionComputeProfileParamsNonStreamingSchema,
2911
+ ])
2912
+ .describe("Parameters for computing a function profile.");
2913
+ })(Request = ComputeProfile.Request || (ComputeProfile.Request = {}));
2914
+ let Response;
2915
+ (function (Response) {
2916
+ Response.FittingStatsSchema = zod_1.default
2917
+ .object({
2918
+ loss: zod_1.default
2919
+ .number()
2920
+ .describe("The final sum loss achieved during weights fitting."),
2921
+ executions: zod_1.default
2922
+ .uint32()
2923
+ .describe("The total number of function executions used during weights fitting."),
2924
+ starts: zod_1.default
2925
+ .uint32()
2926
+ .describe("The number of fitting starts attempted. Each start begins with a randomized weight vector."),
2927
+ rounds: zod_1.default
2928
+ .uint32()
2929
+ .describe("The number of fitting rounds performed across all starts."),
2930
+ errors: zod_1.default
2931
+ .uint32()
2932
+ .describe("The number of errors which occured while computing outputs during fitting."),
2933
+ })
2934
+ .describe("Statistics about the fitting process used to compute the weights for the profile.");
2935
+ let Streaming;
2936
+ (function (Streaming) {
2937
+ Streaming.FunctionExecutionChunkSchema = Executions.Response.Streaming.FunctionExecutionChunkSchema.extend({
2938
+ index: zod_1.default
2939
+ .uint32()
2940
+ .describe("The index of the function execution chunk in the list of executions."),
2941
+ dataset: zod_1.default
2942
+ .uint32()
2943
+ .describe("The index of the dataset item this function execution chunk corresponds to."),
2944
+ n: zod_1.default
2945
+ .uint32()
2946
+ .describe("The N index for this function execution chunk. There will be N function executions, and N comes from the request parameters."),
2947
+ retry: zod_1.default
2948
+ .uint32()
2949
+ .describe("The retry index for this function execution chunk. There may be multiple retries for a given dataset item and N index."),
2950
+ }).describe("A chunk of a function execution ran during profile computation.");
2951
+ let FunctionExecutionChunk;
2952
+ (function (FunctionExecutionChunk) {
575
2953
  function merged(a, b) {
576
- const [delta, deltaChanged] = merge(a.delta, b.delta, Chat.Completions.Response.Streaming.Delta.merged);
577
- const [finish_reason, finish_reasonChanged] = merge(a.finish_reason, b.finish_reason);
578
2954
  const index = a.index;
579
- const [logprobs, logprobsChanged] = merge(a.logprobs, b.logprobs, Chat.Completions.Response.Logprobs.merged);
580
- const [error, errorChanged] = merge(a.error, b.error);
581
- const [model, modelChanged] = merge(a.model, b.model);
582
- const [model_index, model_indexChanged] = merge(a.model_index, b.model_index);
583
- const [completion_metadata, completion_metadataChanged] = merge(a.completion_metadata, b.completion_metadata, Score.Completions.Response.CompletionMetadata.merged);
584
- if (deltaChanged ||
585
- finish_reasonChanged ||
586
- logprobsChanged ||
587
- errorChanged ||
588
- modelChanged ||
589
- model_indexChanged ||
590
- completion_metadataChanged) {
2955
+ const dataset = a.dataset;
2956
+ const n = a.n;
2957
+ const retry = a.retry;
2958
+ const [base, baseChanged] = Executions.Response.Streaming.FunctionExecutionChunk.merged(a, b);
2959
+ if (baseChanged) {
591
2960
  return [
592
- Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ delta,
593
- finish_reason,
594
- index }, (logprobs !== undefined ? { logprobs } : {})), (error !== undefined ? { error } : {})), (model !== undefined ? { model } : {})), (model_index !== undefined ? { model_index } : {})), (completion_metadata !== undefined
595
- ? { completion_metadata }
596
- : {})),
2961
+ Object.assign({ index,
2962
+ dataset,
2963
+ n,
2964
+ retry }, base),
597
2965
  true,
598
2966
  ];
599
2967
  }
@@ -601,205 +2969,322 @@ var Multichat;
601
2969
  return [a, false];
602
2970
  }
603
2971
  }
604
- Choice.merged = merged;
2972
+ FunctionExecutionChunk.merged = merged;
605
2973
  function mergedList(a, b) {
606
2974
  let merged = undefined;
607
- for (const choice of b) {
608
- const existingIndex = a.findIndex(({ index }) => index === choice.index);
2975
+ for (const chunk of b) {
2976
+ const existingIndex = a.findIndex(({ index }) => index === chunk.index);
609
2977
  if (existingIndex === -1) {
610
2978
  if (merged === undefined) {
611
- merged = [...a, choice];
2979
+ merged = [...a, chunk];
612
2980
  }
613
2981
  else {
614
- merged.push(choice);
2982
+ merged.push(chunk);
615
2983
  }
616
2984
  }
617
2985
  else {
618
- const [mergedChoice, choiceChanged] = Choice.merged(a[existingIndex], choice);
619
- if (choiceChanged) {
2986
+ const [mergedChunk, chunkChanged] = FunctionExecutionChunk.merged(a[existingIndex], chunk);
2987
+ if (chunkChanged) {
620
2988
  if (merged === undefined) {
621
2989
  merged = [...a];
622
2990
  }
623
- merged[existingIndex] = mergedChoice;
2991
+ merged[existingIndex] = mergedChunk;
624
2992
  }
625
2993
  }
626
2994
  }
627
2995
  return merged ? [merged, true] : [a, false];
628
2996
  }
629
- Choice.mergedList = mergedList;
630
- })(Choice = Streaming.Choice || (Streaming.Choice = {}));
2997
+ FunctionExecutionChunk.mergedList = mergedList;
2998
+ })(FunctionExecutionChunk = Streaming.FunctionExecutionChunk || (Streaming.FunctionExecutionChunk = {}));
2999
+ Streaming.FunctionComputeProfileChunkSchema = zod_1.default
3000
+ .object({
3001
+ id: zod_1.default
3002
+ .string()
3003
+ .describe("The unique identifier of the function profile computation chunk."),
3004
+ executions: zod_1.default
3005
+ .array(Streaming.FunctionExecutionChunkSchema)
3006
+ .describe("The function executions performed as part of computing the profile."),
3007
+ executions_errors: zod_1.default
3008
+ .boolean()
3009
+ .optional()
3010
+ .describe("When true, indicates that one or more function executions encountered errors during profile computation."),
3011
+ profile: zod_1.default
3012
+ .array(Function_1.ProfileVersionRequiredSchema)
3013
+ .optional()
3014
+ .describe("The computed function profile."),
3015
+ fitting_stats: Response.FittingStatsSchema.optional(),
3016
+ created: zod_1.default
3017
+ .uint32()
3018
+ .describe("The UNIX timestamp (in seconds) when the function profile computation was created."),
3019
+ function: zod_1.default
3020
+ .string()
3021
+ .describe("The unique identifier of the function for which the profile is being computed."),
3022
+ object: zod_1.default.literal("function.compute.profile.chunk"),
3023
+ usage: Vector.Completions.Response.UsageSchema.optional(),
3024
+ })
3025
+ .describe("A chunk of a function profile computation.");
3026
+ let FunctionComputeProfileChunk;
3027
+ (function (FunctionComputeProfileChunk) {
3028
+ function merged(a, b) {
3029
+ const id = a.id;
3030
+ const [executions, executionsChanged] = FunctionExecutionChunk.mergedList(a.executions, b.executions);
3031
+ const [executions_errors, executions_errorsChanged] = merge(a.executions_errors, b.executions_errors);
3032
+ const [profile, profileChanged] = merge(a.profile, b.profile);
3033
+ const [fitting_stats, fitting_statsChanged] = merge(a.fitting_stats, b.fitting_stats);
3034
+ const created = a.created;
3035
+ const function_ = a.function;
3036
+ const object = a.object;
3037
+ const [usage, usageChanged] = merge(a.usage, b.usage);
3038
+ if (executionsChanged ||
3039
+ executions_errorsChanged ||
3040
+ profileChanged ||
3041
+ fitting_statsChanged ||
3042
+ usageChanged) {
3043
+ return [
3044
+ Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ id,
3045
+ executions }, (executions_errors !== undefined
3046
+ ? { executions_errors }
3047
+ : {})), (profile !== undefined ? { profile } : {})), (fitting_stats !== undefined ? { fitting_stats } : {})), { created, function: function_, object }), (usage !== undefined ? { usage } : {})),
3048
+ true,
3049
+ ];
3050
+ }
3051
+ else {
3052
+ return [a, false];
3053
+ }
3054
+ }
3055
+ FunctionComputeProfileChunk.merged = merged;
3056
+ })(FunctionComputeProfileChunk = Streaming.FunctionComputeProfileChunk || (Streaming.FunctionComputeProfileChunk = {}));
631
3057
  })(Streaming = Response.Streaming || (Response.Streaming = {}));
632
- })(Response = Completions.Response || (Completions.Response = {}));
633
- async function list(openai, listOptions, options) {
634
- const response = await openai.get("/multichat/completions", Object.assign({ query: listOptions }, options));
635
- return response;
636
- }
637
- Completions.list = list;
638
- async function publish(openai, id, options) {
639
- await openai.post(`/multichat/completions/${id}/publish`, options);
640
- }
641
- Completions.publish = publish;
642
- async function retrieve(openai, id, options) {
643
- const response = await openai.get(`/multichat/completions/${id}`, options);
3058
+ let Unary;
3059
+ (function (Unary) {
3060
+ Unary.FunctionExecutionSchema = Executions.Response.Unary.FunctionExecutionSchema.extend({
3061
+ index: zod_1.default
3062
+ .uint32()
3063
+ .describe("The index of the function execution in the list of executions."),
3064
+ dataset: zod_1.default
3065
+ .uint32()
3066
+ .describe("The index of the dataset item this function execution corresponds to."),
3067
+ n: zod_1.default
3068
+ .uint32()
3069
+ .describe("The N index for this function execution. There will be N function executions, and N comes from the request parameters."),
3070
+ retry: zod_1.default
3071
+ .uint32()
3072
+ .describe("The retry index for this function execution. There may be multiple retries for a given dataset item and N index."),
3073
+ }).describe("A function execution ran during profile computation.");
3074
+ Unary.FunctionComputeProfileSchema = zod_1.default
3075
+ .object({
3076
+ id: zod_1.default
3077
+ .string()
3078
+ .describe("The unique identifier of the function profile computation."),
3079
+ executions: zod_1.default
3080
+ .array(Unary.FunctionExecutionSchema)
3081
+ .describe("The function executions performed as part of computing the profile."),
3082
+ executions_errors: zod_1.default
3083
+ .boolean()
3084
+ .describe("When true, indicates that one or more function executions encountered errors during profile computation."),
3085
+ profile: zod_1.default
3086
+ .array(Function_1.ProfileVersionRequiredSchema)
3087
+ .describe("The computed function profile."),
3088
+ fitting_stats: Response.FittingStatsSchema,
3089
+ created: zod_1.default
3090
+ .uint32()
3091
+ .describe("The UNIX timestamp (in seconds) when the function profile computation was created."),
3092
+ function: zod_1.default
3093
+ .string()
3094
+ .describe("The unique identifier of the function for which the profile is being computed."),
3095
+ object: zod_1.default.literal("function.compute.profile"),
3096
+ usage: Vector.Completions.Response.UsageSchema,
3097
+ })
3098
+ .describe("A function profile computation.");
3099
+ })(Unary = Response.Unary || (Response.Unary = {}));
3100
+ })(Response = ComputeProfile.Response || (ComputeProfile.Response = {}));
3101
+ })(ComputeProfile = Function_1.ComputeProfile || (Function_1.ComputeProfile = {}));
3102
+ let Profile;
3103
+ (function (Profile) {
3104
+ Profile.ListItemSchema = zod_1.default.object({
3105
+ function_author: zod_1.default
3106
+ .string()
3107
+ .describe("The author of the function the profile was published to."),
3108
+ function_id: zod_1.default
3109
+ .string()
3110
+ .describe("The unique identifier of the function the profile was published to."),
3111
+ author: zod_1.default.string().describe("The author of the profile."),
3112
+ id: zod_1.default.string().describe("The unique identifier of the profile."),
3113
+ version: zod_1.default.uint32().describe("The version of the profile."),
3114
+ });
3115
+ async function list(openai, options) {
3116
+ const response = await openai.get("/functions/profiles", options);
644
3117
  return response;
645
3118
  }
646
- Completions.retrieve = retrieve;
647
- async function create(openai, body, options) {
648
- var _a;
649
- const response = await openai.post("/multichat/completions", Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
3119
+ Profile.list = list;
3120
+ Profile.RetrieveItemSchema = zod_1.default.object({
3121
+ created: zod_1.default
3122
+ .uint32()
3123
+ .describe("The UNIX timestamp (in seconds) when the profile was created."),
3124
+ shape: zod_1.default
3125
+ .string()
3126
+ .describe("The shape of the profile. Unless Task Skip expressions work out favorably, profiles only work for functions with the same shape."),
3127
+ function_author: zod_1.default
3128
+ .string()
3129
+ .describe("The author of the function the profile was published to."),
3130
+ function_id: zod_1.default
3131
+ .string()
3132
+ .describe("The unique identifier of the function the profile was published to."),
3133
+ author: zod_1.default.string().describe("The author of the profile."),
3134
+ id: zod_1.default.string().describe("The unique identifier of the profile."),
3135
+ version: zod_1.default.uint32().describe("The version of the profile."),
3136
+ profile: zod_1.default
3137
+ .array(Function.ProfileVersionRequiredSchema)
3138
+ .describe("The function profile."),
3139
+ });
3140
+ async function retrieve(openai, function_author, function_id, author, id, version, options) {
3141
+ const response = await openai.get(version !== null && version !== undefined
3142
+ ? `/functions/${function_author}/${function_id}/profiles/${author}/${id}/${version}`
3143
+ : `/functions/${function_author}/${function_id}/profiles/${author}/${id}`, options);
650
3144
  return response;
651
3145
  }
652
- Completions.create = create;
653
- })(Completions = Multichat.Completions || (Multichat.Completions = {}));
654
- })(Multichat || (exports.Multichat = Multichat = {}));
655
- var Conversation;
656
- (function (Conversation) {
657
- let Completions;
658
- (function (Completions) {
659
- async function list(openai, listOptions, options) {
660
- const response = await openai.get("/conversation/completions", Object.assign({ query: listOptions }, options));
3146
+ Profile.retrieve = retrieve;
3147
+ Profile.HistoricalUsageSchema = zod_1.default.object({
3148
+ requests: zod_1.default
3149
+ .uint32()
3150
+ .describe("The total number of requests made to Functions while using this Profile."),
3151
+ completion_tokens: zod_1.default
3152
+ .uint32()
3153
+ .describe("The total number of completion tokens generated by Functions while using this Profile."),
3154
+ prompt_tokens: zod_1.default
3155
+ .uint32()
3156
+ .describe("The total number of prompt tokens sent to Functions while using this Profile."),
3157
+ total_cost: zod_1.default
3158
+ .number()
3159
+ .describe("The total cost incurred by using this Profile."),
3160
+ });
3161
+ async function retrieveUsage(openai, function_author, function_id, author, id, version, options) {
3162
+ const response = await openai.get(version !== null && version !== undefined
3163
+ ? `/functions/${function_author}/${function_id}/profiles/${author}/${id}/${version}/usage`
3164
+ : `/functions/${function_author}/${function_id}/profiles/${author}/${id}/usage`, options);
661
3165
  return response;
662
3166
  }
663
- Completions.list = list;
664
- })(Completions = Conversation.Completions || (Conversation.Completions = {}));
665
- })(Conversation || (exports.Conversation = Conversation = {}));
666
- var Functions;
667
- (function (Functions) {
668
- let Response;
669
- (function (Response) {
670
- let Streaming;
671
- (function (Streaming) {
672
- let CompletionChunk;
673
- (function (CompletionChunk) {
674
- let ScoreCompletionChunk;
675
- (function (ScoreCompletionChunk) {
676
- function merged(a, b) {
677
- const [base, baseChanged] = Score.Completions.Response.Streaming.ChatCompletionChunk.merged(a, b);
678
- return baseChanged
679
- ? [Object.assign(Object.assign({ type: a.type }, base), { index: a.index }), true]
680
- : [a, false];
681
- }
682
- ScoreCompletionChunk.merged = merged;
683
- })(ScoreCompletionChunk = CompletionChunk.ScoreCompletionChunk || (CompletionChunk.ScoreCompletionChunk = {}));
684
- let MultichatCompletionChunk;
685
- (function (MultichatCompletionChunk) {
686
- function merged(a, b) {
687
- const [base, baseChanged] = Multichat.Completions.Response.Streaming.ChatCompletionChunk.merged(a, b);
688
- return baseChanged
689
- ? [Object.assign(Object.assign({ type: a.type }, base), { index: a.index }), true]
690
- : [a, false];
691
- }
692
- MultichatCompletionChunk.merged = merged;
693
- })(MultichatCompletionChunk = CompletionChunk.MultichatCompletionChunk || (CompletionChunk.MultichatCompletionChunk = {}));
694
- function mergedList(a, b) {
695
- let merged = undefined;
696
- for (const chunk of b) {
697
- const existingIndex = a.findIndex((c) => c.index === chunk.index && c.type === chunk.type);
698
- if (existingIndex === -1) {
699
- if (merged === undefined) {
700
- merged = [...a, chunk];
701
- }
702
- else {
703
- merged.push(chunk);
704
- }
705
- }
706
- else if (chunk.type === "score") {
707
- const [mergedChunk, chunkChanged] = ScoreCompletionChunk.merged(a[existingIndex], chunk);
708
- if (chunkChanged) {
709
- if (merged === undefined) {
710
- merged = [...a];
711
- }
712
- merged[existingIndex] = mergedChunk;
713
- }
714
- }
715
- else if (chunk.type === "multichat") {
716
- const [mergedChunk, chunkChanged] = MultichatCompletionChunk.merged(a[existingIndex], chunk);
717
- if (chunkChanged) {
718
- if (merged === undefined) {
719
- merged = [...a];
720
- }
721
- merged[existingIndex] = mergedChunk;
722
- }
723
- }
724
- }
725
- return merged ? [merged, true] : [a, false];
726
- }
727
- CompletionChunk.mergedList = mergedList;
728
- })(CompletionChunk = Streaming.CompletionChunk || (Streaming.CompletionChunk = {}));
729
- function merged(a, b) {
730
- const [completions, completionsChanged] = CompletionChunk.mergedList(a.completions, b.completions);
731
- const [output, outputChanged] = merge(a.output, b.output);
732
- const [retry_token, retry_tokenChanged] = merge(a.retry_token, b.retry_token);
733
- const [error, errorChanged] = merge(a.error, b.error);
734
- const [function_published, function_publishedChanged] = merge(a.function_published, b.function_published);
735
- if (completionsChanged ||
736
- outputChanged ||
737
- retry_tokenChanged ||
738
- errorChanged ||
739
- function_publishedChanged) {
740
- return [
741
- Object.assign(Object.assign(Object.assign(Object.assign({ completions }, (output !== undefined ? { output } : {})), (retry_token !== undefined ? { retry_token } : {})), (error !== undefined ? { error } : {})), (function_published !== undefined
742
- ? { function_published }
743
- : {})),
744
- true,
745
- ];
746
- }
747
- else {
748
- return [a, false];
749
- }
750
- }
751
- Streaming.merged = merged;
752
- })(Streaming = Response.Streaming || (Response.Streaming = {}));
753
- })(Response = Functions.Response || (Functions.Response = {}));
754
- async function list(openai, listOptions, options) {
755
- const response = await openai.get("/functions", Object.assign({ query: listOptions }, options));
3167
+ Profile.retrieveUsage = retrieveUsage;
3168
+ })(Profile = Function_1.Profile || (Function_1.Profile = {}));
3169
+ async function executeInline(openai, body, options) {
3170
+ var _a;
3171
+ const response = await openai.post("/functions", Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
756
3172
  return response;
757
3173
  }
758
- Functions.list = list;
759
- async function count(openai, options) {
760
- const response = await openai.get("/functions/count", options);
3174
+ Function_1.executeInline = executeInline;
3175
+ async function execute(openai, author, id, version, body, options) {
3176
+ var _a;
3177
+ const response = await openai.post(version !== null && version !== undefined
3178
+ ? `/functions/${author}/${id}/${version}`
3179
+ : `/functions/${author}/${id}`, Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
761
3180
  return response;
762
3181
  }
763
- Functions.count = count;
764
- async function retrieve(openai, author, id, version, retrieveOptions, options) {
765
- const url = version !== null && version !== undefined
766
- ? `/functions/${author}/${id}/${version}`
767
- : `/functions/${author}/${id}`;
768
- const response = await openai.get(url, Object.assign({ query: retrieveOptions }, options));
3182
+ Function_1.execute = execute;
3183
+ async function publishFunction(openai, author, id, version, body, options) {
3184
+ var _a;
3185
+ const response = await openai.post(`/functions/${author}/${id}/${version}/publish`, Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
769
3186
  return response;
770
3187
  }
771
- Functions.retrieve = retrieve;
772
- async function executeById(openai, author, id, version, body, options) {
3188
+ Function_1.publishFunction = publishFunction;
3189
+ async function publishProfile(openai, function_author, function_id, body, options) {
773
3190
  var _a;
774
- const url = version !== null && version !== undefined
775
- ? `/functions/${author}/${id}/${version}`
776
- : `/functions/${author}/${id}`;
777
- const response = await openai.post(url, Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
3191
+ const response = await openai.post(`/functions/${function_author}/${function_id}/profiles/publish`, Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
778
3192
  return response;
779
3193
  }
780
- Functions.executeById = executeById;
781
- async function executeByDefinition(openai, body, options) {
3194
+ Function_1.publishProfile = publishProfile;
3195
+ async function computeProfile(openai, author, id, version, body, options) {
782
3196
  var _a;
783
- const response = await openai.post("/functions", Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
3197
+ const response = await openai.post(version !== null && version !== undefined
3198
+ ? `/functions/${author}/${id}/${version}/profiles/compute`
3199
+ : `/functions/${author}/${id}/profiles/compute`, Object.assign({ body, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false }, options));
3200
+ return response;
3201
+ }
3202
+ Function_1.computeProfile = computeProfile;
3203
+ Function_1.ListItemSchema = zod_1.default.object({
3204
+ author: zod_1.default.string().describe("The author of the function."),
3205
+ id: zod_1.default.string().describe("The unique identifier of the function."),
3206
+ version: zod_1.default.uint32().describe("The version of the function."),
3207
+ });
3208
+ async function list(openai, options) {
3209
+ const response = await openai.get("/functions", options);
784
3210
  return response;
785
3211
  }
786
- Functions.executeByDefinition = executeByDefinition;
787
- })(Functions || (exports.Functions = Functions = {}));
788
- var Models;
789
- (function (Models) {
790
- async function list(openai, listOptions, options) {
791
- const response = await openai.models.list(Object.assign({ query: listOptions }, options));
3212
+ Function_1.list = list;
3213
+ Function_1.ScalarRetrieveItemSchema = Function_1.ScalarSchema.extend({
3214
+ created: zod_1.default
3215
+ .uint32()
3216
+ .describe("The UNIX timestamp (in seconds) when the function was created."),
3217
+ shape: zod_1.default
3218
+ .string()
3219
+ .describe("The shape of the function. Unless Task Skip expressions work out favorably, functions only work with profiles that have the same shape."),
3220
+ });
3221
+ Function_1.VectorRetrieveItemSchema = Function_1.VectorSchema.extend({
3222
+ created: zod_1.default
3223
+ .uint32()
3224
+ .describe("The UNIX timestamp (in seconds) when the function was created."),
3225
+ shape: zod_1.default
3226
+ .string()
3227
+ .describe("The shape of the function. Unless Task Skip expressions work out favorably, functions only work with profiles that have the same shape."),
3228
+ });
3229
+ Function_1.RetrieveItemSchema = zod_1.default.discriminatedUnion("type", [
3230
+ Function_1.ScalarRetrieveItemSchema,
3231
+ Function_1.VectorRetrieveItemSchema,
3232
+ ]);
3233
+ async function retrieve(openai, author, id, version, options) {
3234
+ const response = await openai.get(version !== null && version !== undefined
3235
+ ? `/functions/${author}/${id}/${version}`
3236
+ : `/functions/${author}/${id}`, options);
792
3237
  return response;
793
3238
  }
794
- Models.list = list;
795
- async function retrieve(openai, model, retrieveOptions, options) {
796
- const response = await openai.models.retrieve(model, Object.assign({ query: retrieveOptions }, options));
3239
+ Function_1.retrieve = retrieve;
3240
+ Function_1.HistoricalUsageSchema = zod_1.default.object({
3241
+ requests: zod_1.default
3242
+ .uint32()
3243
+ .describe("The total number of requests made to this Function."),
3244
+ completion_tokens: zod_1.default
3245
+ .uint32()
3246
+ .describe("The total number of completion tokens generated by this Function."),
3247
+ prompt_tokens: zod_1.default
3248
+ .uint32()
3249
+ .describe("The total number of prompt tokens sent to this Function."),
3250
+ total_cost: zod_1.default
3251
+ .number()
3252
+ .describe("The total cost incurred by using this Function."),
3253
+ });
3254
+ async function retrieveUsage(openai, author, id, version, options) {
3255
+ const response = await openai.get(version !== null && version !== undefined
3256
+ ? `/functions/${author}/${id}/${version}/usage`
3257
+ : `/functions/${author}/${id}/usage`, options);
797
3258
  return response;
798
3259
  }
799
- Models.retrieve = retrieve;
800
- })(Models || (exports.Models = Models = {}));
3260
+ Function_1.retrieveUsage = retrieveUsage;
3261
+ })(Function || (exports.Function = Function = {}));
801
3262
  var Auth;
802
3263
  (function (Auth) {
3264
+ Auth.ApiKeySchema = zod_1.default.object({
3265
+ api_key: zod_1.default.string().describe("The API key."),
3266
+ created: zod_1.default
3267
+ .string()
3268
+ .describe("The RFC 3339 timestamp when the API key was created."),
3269
+ expires: zod_1.default
3270
+ .string()
3271
+ .nullable()
3272
+ .describe("The RFC 3339 timestamp when the API key expires, or null if it does not expire."),
3273
+ disabled: zod_1.default
3274
+ .string()
3275
+ .nullable()
3276
+ .describe("The RFC 3339 timestamp when the API key was disabled, or null if it is not disabled."),
3277
+ name: zod_1.default.string().describe("The name of the API key."),
3278
+ description: zod_1.default
3279
+ .string()
3280
+ .nullable()
3281
+ .describe("The description of the API key, or null if no description was provided."),
3282
+ });
3283
+ Auth.ApiKeyWithCostSchema = Auth.ApiKeySchema.extend({
3284
+ cost: zod_1.default
3285
+ .number()
3286
+ .describe("The total cost incurred while using this API key."),
3287
+ });
803
3288
  let ApiKey;
804
3289
  (function (ApiKey) {
805
3290
  async function list(openai, options) {
@@ -824,6 +3309,9 @@ var Auth;
824
3309
  }
825
3310
  ApiKey.remove = remove;
826
3311
  })(ApiKey = Auth.ApiKey || (Auth.ApiKey = {}));
3312
+ Auth.OpenRouterApiKeySchema = zod_1.default.object({
3313
+ api_key: zod_1.default.string().describe("The OpenRouter API key."),
3314
+ });
827
3315
  let OpenRouterApiKey;
828
3316
  (function (OpenRouterApiKey) {
829
3317
  async function retrieve(openai, options) {
@@ -844,6 +3332,15 @@ var Auth;
844
3332
  }
845
3333
  OpenRouterApiKey.remove = remove;
846
3334
  })(OpenRouterApiKey = Auth.OpenRouterApiKey || (Auth.OpenRouterApiKey = {}));
3335
+ Auth.CreditsSchema = zod_1.default.object({
3336
+ credits: zod_1.default.number().describe("The current number of credits available."),
3337
+ total_credits_purchased: zod_1.default
3338
+ .number()
3339
+ .describe("The total number of credits ever purchased."),
3340
+ total_credits_used: zod_1.default
3341
+ .number()
3342
+ .describe("The total number of credits ever used."),
3343
+ });
847
3344
  let Credits;
848
3345
  (function (Credits) {
849
3346
  async function retrieve(openai, options) {
@@ -866,106 +3363,6 @@ var Auth;
866
3363
  Username.set = set;
867
3364
  })(Username = Auth.Username || (Auth.Username = {}));
868
3365
  })(Auth || (exports.Auth = Auth = {}));
869
- var Metadata;
870
- (function (Metadata) {
871
- async function get(openai, options) {
872
- const response = await openai.get("/metadata", options);
873
- return response;
874
- }
875
- Metadata.get = get;
876
- })(Metadata || (exports.Metadata = Metadata = {}));
877
- var ScoreLlm;
878
- (function (ScoreLlm) {
879
- async function list(openai, listOptions, options) {
880
- const response = await openai.get("/score/llms", Object.assign({ query: listOptions }, options));
881
- return response;
882
- }
883
- ScoreLlm.list = list;
884
- async function count(openai, options) {
885
- const response = await openai.get("/score/llms/count", options);
886
- return response;
887
- }
888
- ScoreLlm.count = count;
889
- async function retrieve(openai, model, retrieveOptions, options) {
890
- const response = await openai.get(`/score/llms/${model}`, Object.assign({ query: retrieveOptions }, options));
891
- return response;
892
- }
893
- ScoreLlm.retrieve = retrieve;
894
- async function retrieveValidate(openai, model, retrieveOptions, options) {
895
- const response = await openai.post("/score/llms", Object.assign({ query: retrieveOptions, body: model }, options));
896
- return response;
897
- }
898
- ScoreLlm.retrieveValidate = retrieveValidate;
899
- })(ScoreLlm || (exports.ScoreLlm = ScoreLlm = {}));
900
- var MultichatLlm;
901
- (function (MultichatLlm) {
902
- async function list(openai, listOptions, options) {
903
- const response = await openai.get("/multichat/llms", Object.assign({ query: listOptions }, options));
904
- return response;
905
- }
906
- MultichatLlm.list = list;
907
- async function count(openai, options) {
908
- const response = await openai.get("/multichat/llms/count", options);
909
- return response;
910
- }
911
- MultichatLlm.count = count;
912
- async function retrieve(openai, model, retrieveOptions, options) {
913
- const response = await openai.get(`/multichat/llms/${model}`, Object.assign({ query: retrieveOptions }, options));
914
- return response;
915
- }
916
- MultichatLlm.retrieve = retrieve;
917
- async function retrieveValidate(openai, model, retrieveOptions, options) {
918
- const response = await openai.post("/multichat/llms", Object.assign({ query: retrieveOptions, body: model }, options));
919
- return response;
920
- }
921
- MultichatLlm.retrieveValidate = retrieveValidate;
922
- })(MultichatLlm || (exports.MultichatLlm = MultichatLlm = {}));
923
- var ScoreModel;
924
- (function (ScoreModel) {
925
- async function list(openai, listOptions, options) {
926
- const response = await openai.get("/score/models", Object.assign({ query: listOptions }, options));
927
- return response;
928
- }
929
- ScoreModel.list = list;
930
- async function count(openai, options) {
931
- const response = await openai.get("/score/models/count", options);
932
- return response;
933
- }
934
- ScoreModel.count = count;
935
- async function retrieve(openai, model, retrieveOptions, options) {
936
- const response = await openai.get(`/score/models/${model}`, Object.assign({ query: retrieveOptions }, options));
937
- return response;
938
- }
939
- ScoreModel.retrieve = retrieve;
940
- async function retrieveValidate(openai, model, retrieveOptions, options) {
941
- const response = await openai.post("/score/models", Object.assign({ query: retrieveOptions, body: model }, options));
942
- return response;
943
- }
944
- ScoreModel.retrieveValidate = retrieveValidate;
945
- })(ScoreModel || (exports.ScoreModel = ScoreModel = {}));
946
- var MultichatModel;
947
- (function (MultichatModel) {
948
- async function list(openai, listOptions, options) {
949
- const response = await openai.get("/multichat/models", Object.assign({ query: listOptions }, options));
950
- return response;
951
- }
952
- MultichatModel.list = list;
953
- async function count(openai, options) {
954
- const response = await openai.get("/multichat/models/count", options);
955
- return response;
956
- }
957
- MultichatModel.count = count;
958
- async function retrieve(openai, model, retrieveOptions, options) {
959
- const response = await openai.get(`/multichat/models/${model}`, Object.assign({ query: retrieveOptions }, options));
960
- return response;
961
- }
962
- MultichatModel.retrieve = retrieve;
963
- async function retrieveValidate(openai, model, retrieveOptions, options) {
964
- const response = await openai.post("/multichat/models", Object.assign({ query: retrieveOptions, body: model }, options));
965
- return response;
966
- }
967
- MultichatModel.retrieveValidate = retrieveValidate;
968
- })(MultichatModel || (exports.MultichatModel = MultichatModel = {}));
969
3366
  function merge(a, b, combine) {
970
3367
  if (a !== null && a !== undefined && b !== null && b !== undefined) {
971
3368
  return combine ? combine(a, b) : [a, false];
@@ -986,6 +3383,6 @@ function merge(a, b, combine) {
986
3383
  function mergedString(a, b) {
987
3384
  return b === "" ? [a, false] : [a + b, true];
988
3385
  }
989
- function mergedNumber(a, b) {
990
- return b === 0 ? [a, false] : [a + b, true];
991
- }
3386
+ // function mergedNumber(a: number, b: number): [number, boolean] {
3387
+ // return b === 0 ? [a, false] : [a + b, true];
3388
+ // }