objectiveai 1.1.12 → 1.2.1

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