@ai-sdk/openai 2.0.0-canary.2 → 2.0.0-canary.3
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.
- package/CHANGELOG.md +15 -0
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +397 -215
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +366 -178
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.d.mts +67 -2
- package/internal/dist/index.d.ts +67 -2
- package/internal/dist/index.js +388 -212
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +359 -178
- package/internal/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/internal/dist/index.js
CHANGED
|
@@ -25,18 +25,18 @@ __export(internal_exports, {
|
|
|
25
25
|
OpenAIEmbeddingModel: () => OpenAIEmbeddingModel,
|
|
26
26
|
OpenAIImageModel: () => OpenAIImageModel,
|
|
27
27
|
OpenAIResponsesLanguageModel: () => OpenAIResponsesLanguageModel,
|
|
28
|
+
OpenAITranscriptionModel: () => OpenAITranscriptionModel,
|
|
28
29
|
modelMaxImagesPerCall: () => modelMaxImagesPerCall
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(internal_exports);
|
|
31
32
|
|
|
32
33
|
// src/openai-chat-language-model.ts
|
|
33
34
|
var import_provider3 = require("@ai-sdk/provider");
|
|
34
|
-
var
|
|
35
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
35
36
|
var import_zod2 = require("zod");
|
|
36
37
|
|
|
37
38
|
// src/convert-to-openai-chat-messages.ts
|
|
38
39
|
var import_provider = require("@ai-sdk/provider");
|
|
39
|
-
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
40
40
|
function convertToOpenAIChatMessages({
|
|
41
41
|
prompt,
|
|
42
42
|
useLegacyFunctionCalling = false,
|
|
@@ -80,55 +80,65 @@ function convertToOpenAIChatMessages({
|
|
|
80
80
|
messages.push({
|
|
81
81
|
role: "user",
|
|
82
82
|
content: content.map((part, index) => {
|
|
83
|
-
var _a, _b, _c
|
|
83
|
+
var _a, _b, _c;
|
|
84
84
|
switch (part.type) {
|
|
85
85
|
case "text": {
|
|
86
86
|
return { type: "text", text: part.text };
|
|
87
87
|
}
|
|
88
|
-
case "image": {
|
|
89
|
-
return {
|
|
90
|
-
type: "image_url",
|
|
91
|
-
image_url: {
|
|
92
|
-
url: part.image instanceof URL ? part.image.toString() : `data:${(_a = part.mimeType) != null ? _a : "image/jpeg"};base64,${(0, import_provider_utils.convertUint8ArrayToBase64)(part.image)}`,
|
|
93
|
-
// OpenAI specific extension: image detail
|
|
94
|
-
detail: (_c = (_b = part.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.imageDetail
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
88
|
case "file": {
|
|
99
|
-
if (part.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
type: "input_audio",
|
|
115
|
-
input_audio: { data: part.data, format: "mp3" }
|
|
116
|
-
};
|
|
89
|
+
if (part.mediaType.startsWith("image/")) {
|
|
90
|
+
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
91
|
+
return {
|
|
92
|
+
type: "image_url",
|
|
93
|
+
image_url: {
|
|
94
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`,
|
|
95
|
+
// OpenAI specific extension: image detail
|
|
96
|
+
detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
} else if (part.mediaType.startsWith("audio/")) {
|
|
100
|
+
if (part.data instanceof URL) {
|
|
101
|
+
throw new import_provider.UnsupportedFunctionalityError({
|
|
102
|
+
functionality: "audio file parts with URLs"
|
|
103
|
+
});
|
|
117
104
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
105
|
+
switch (part.mediaType) {
|
|
106
|
+
case "audio/wav": {
|
|
107
|
+
return {
|
|
108
|
+
type: "input_audio",
|
|
109
|
+
input_audio: { data: part.data, format: "wav" }
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
case "audio/mp3":
|
|
113
|
+
case "audio/mpeg": {
|
|
114
|
+
return {
|
|
115
|
+
type: "input_audio",
|
|
116
|
+
input_audio: { data: part.data, format: "mp3" }
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
default: {
|
|
120
|
+
throw new import_provider.UnsupportedFunctionalityError({
|
|
121
|
+
functionality: `audio content parts with media type ${part.mediaType}`
|
|
122
|
+
});
|
|
123
|
+
}
|
|
126
124
|
}
|
|
127
|
-
|
|
125
|
+
} else if (part.mediaType === "application/pdf") {
|
|
126
|
+
if (part.data instanceof URL) {
|
|
128
127
|
throw new import_provider.UnsupportedFunctionalityError({
|
|
129
|
-
functionality:
|
|
128
|
+
functionality: "PDF file parts with URLs"
|
|
130
129
|
});
|
|
131
130
|
}
|
|
131
|
+
return {
|
|
132
|
+
type: "file",
|
|
133
|
+
file: {
|
|
134
|
+
filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
|
|
135
|
+
file_data: `data:application/pdf;base64,${part.data}`
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
} else {
|
|
139
|
+
throw new import_provider.UnsupportedFunctionalityError({
|
|
140
|
+
functionality: `file part media type ${part.mediaType}`
|
|
141
|
+
});
|
|
132
142
|
}
|
|
133
143
|
}
|
|
134
144
|
}
|
|
@@ -237,7 +247,7 @@ function mapOpenAIFinishReason(finishReason) {
|
|
|
237
247
|
|
|
238
248
|
// src/openai-error.ts
|
|
239
249
|
var import_zod = require("zod");
|
|
240
|
-
var
|
|
250
|
+
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
241
251
|
var openaiErrorDataSchema = import_zod.z.object({
|
|
242
252
|
error: import_zod.z.object({
|
|
243
253
|
message: import_zod.z.string(),
|
|
@@ -249,7 +259,7 @@ var openaiErrorDataSchema = import_zod.z.object({
|
|
|
249
259
|
code: import_zod.z.union([import_zod.z.string(), import_zod.z.number()]).nullish()
|
|
250
260
|
})
|
|
251
261
|
});
|
|
252
|
-
var openaiFailedResponseHandler = (0,
|
|
262
|
+
var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
|
|
253
263
|
errorSchema: openaiErrorDataSchema,
|
|
254
264
|
errorToMessage: (data) => data.error.message
|
|
255
265
|
});
|
|
@@ -361,7 +371,7 @@ function prepareTools({
|
|
|
361
371
|
default: {
|
|
362
372
|
const _exhaustiveCheck = type;
|
|
363
373
|
throw new import_provider2.UnsupportedFunctionalityError({
|
|
364
|
-
functionality: `
|
|
374
|
+
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
365
375
|
});
|
|
366
376
|
}
|
|
367
377
|
}
|
|
@@ -568,15 +578,15 @@ var OpenAIChatLanguageModel = class {
|
|
|
568
578
|
responseHeaders,
|
|
569
579
|
value: response,
|
|
570
580
|
rawValue: rawResponse
|
|
571
|
-
} = await (0,
|
|
581
|
+
} = await (0, import_provider_utils2.postJsonToApi)({
|
|
572
582
|
url: this.config.url({
|
|
573
583
|
path: "/chat/completions",
|
|
574
584
|
modelId: this.modelId
|
|
575
585
|
}),
|
|
576
|
-
headers: (0,
|
|
586
|
+
headers: (0, import_provider_utils2.combineHeaders)(this.config.headers(), options.headers),
|
|
577
587
|
body,
|
|
578
588
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
579
|
-
successfulResponseHandler: (0,
|
|
589
|
+
successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
|
|
580
590
|
openaiChatResponseSchema
|
|
581
591
|
),
|
|
582
592
|
abortSignal: options.abortSignal,
|
|
@@ -604,7 +614,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
604
614
|
toolCalls: this.settings.useLegacyFunctionCalling && choice.message.function_call ? [
|
|
605
615
|
{
|
|
606
616
|
toolCallType: "function",
|
|
607
|
-
toolCallId: (0,
|
|
617
|
+
toolCallId: (0, import_provider_utils2.generateId)(),
|
|
608
618
|
toolName: choice.message.function_call.name,
|
|
609
619
|
args: choice.message.function_call.arguments
|
|
610
620
|
}
|
|
@@ -612,7 +622,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
612
622
|
var _a2;
|
|
613
623
|
return {
|
|
614
624
|
toolCallType: "function",
|
|
615
|
-
toolCallId: (_a2 = toolCall.id) != null ? _a2 : (0,
|
|
625
|
+
toolCallId: (_a2 = toolCall.id) != null ? _a2 : (0, import_provider_utils2.generateId)(),
|
|
616
626
|
toolName: toolCall.function.name,
|
|
617
627
|
args: toolCall.function.arguments
|
|
618
628
|
};
|
|
@@ -682,15 +692,15 @@ var OpenAIChatLanguageModel = class {
|
|
|
682
692
|
// only include stream_options when in strict compatibility mode:
|
|
683
693
|
stream_options: this.config.compatibility === "strict" ? { include_usage: true } : void 0
|
|
684
694
|
};
|
|
685
|
-
const { responseHeaders, value: response } = await (0,
|
|
695
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils2.postJsonToApi)({
|
|
686
696
|
url: this.config.url({
|
|
687
697
|
path: "/chat/completions",
|
|
688
698
|
modelId: this.modelId
|
|
689
699
|
}),
|
|
690
|
-
headers: (0,
|
|
700
|
+
headers: (0, import_provider_utils2.combineHeaders)(this.config.headers(), options.headers),
|
|
691
701
|
body,
|
|
692
702
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
693
|
-
successfulResponseHandler: (0,
|
|
703
|
+
successfulResponseHandler: (0, import_provider_utils2.createEventSourceResponseHandler)(
|
|
694
704
|
openaiChatChunkSchema
|
|
695
705
|
),
|
|
696
706
|
abortSignal: options.abortSignal,
|
|
@@ -778,7 +788,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
778
788
|
const mappedToolCalls = useLegacyFunctionCalling && delta.function_call != null ? [
|
|
779
789
|
{
|
|
780
790
|
type: "function",
|
|
781
|
-
id: (0,
|
|
791
|
+
id: (0, import_provider_utils2.generateId)(),
|
|
782
792
|
function: delta.function_call,
|
|
783
793
|
index: 0
|
|
784
794
|
}
|
|
@@ -825,11 +835,11 @@ var OpenAIChatLanguageModel = class {
|
|
|
825
835
|
argsTextDelta: toolCall2.function.arguments
|
|
826
836
|
});
|
|
827
837
|
}
|
|
828
|
-
if ((0,
|
|
838
|
+
if ((0, import_provider_utils2.isParsableJson)(toolCall2.function.arguments)) {
|
|
829
839
|
controller.enqueue({
|
|
830
840
|
type: "tool-call",
|
|
831
841
|
toolCallType: "function",
|
|
832
|
-
toolCallId: (_e = toolCall2.id) != null ? _e : (0,
|
|
842
|
+
toolCallId: (_e = toolCall2.id) != null ? _e : (0, import_provider_utils2.generateId)(),
|
|
833
843
|
toolName: toolCall2.function.name,
|
|
834
844
|
args: toolCall2.function.arguments
|
|
835
845
|
});
|
|
@@ -852,11 +862,11 @@ var OpenAIChatLanguageModel = class {
|
|
|
852
862
|
toolName: toolCall.function.name,
|
|
853
863
|
argsTextDelta: (_i = toolCallDelta.function.arguments) != null ? _i : ""
|
|
854
864
|
});
|
|
855
|
-
if (((_j = toolCall.function) == null ? void 0 : _j.name) != null && ((_k = toolCall.function) == null ? void 0 : _k.arguments) != null && (0,
|
|
865
|
+
if (((_j = toolCall.function) == null ? void 0 : _j.name) != null && ((_k = toolCall.function) == null ? void 0 : _k.arguments) != null && (0, import_provider_utils2.isParsableJson)(toolCall.function.arguments)) {
|
|
856
866
|
controller.enqueue({
|
|
857
867
|
type: "tool-call",
|
|
858
868
|
toolCallType: "function",
|
|
859
|
-
toolCallId: (_l = toolCall.id) != null ? _l : (0,
|
|
869
|
+
toolCallId: (_l = toolCall.id) != null ? _l : (0, import_provider_utils2.generateId)(),
|
|
860
870
|
toolName: toolCall.function.name,
|
|
861
871
|
args: toolCall.function.arguments
|
|
862
872
|
});
|
|
@@ -1026,7 +1036,7 @@ var reasoningModels = {
|
|
|
1026
1036
|
};
|
|
1027
1037
|
|
|
1028
1038
|
// src/openai-completion-language-model.ts
|
|
1029
|
-
var
|
|
1039
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
1030
1040
|
var import_zod3 = require("zod");
|
|
1031
1041
|
|
|
1032
1042
|
// src/convert-to-openai-completion-prompt.ts
|
|
@@ -1061,13 +1071,8 @@ function convertToOpenAICompletionPrompt({
|
|
|
1061
1071
|
case "text": {
|
|
1062
1072
|
return part.text;
|
|
1063
1073
|
}
|
|
1064
|
-
case "image": {
|
|
1065
|
-
throw new import_provider4.UnsupportedFunctionalityError({
|
|
1066
|
-
functionality: "images"
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
1074
|
}
|
|
1070
|
-
}).join("");
|
|
1075
|
+
}).filter(Boolean).join("");
|
|
1071
1076
|
text += `${user}:
|
|
1072
1077
|
${userMessage}
|
|
1073
1078
|
|
|
@@ -1204,15 +1209,15 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1204
1209
|
responseHeaders,
|
|
1205
1210
|
value: response,
|
|
1206
1211
|
rawValue: rawResponse
|
|
1207
|
-
} = await (0,
|
|
1212
|
+
} = await (0, import_provider_utils3.postJsonToApi)({
|
|
1208
1213
|
url: this.config.url({
|
|
1209
1214
|
path: "/completions",
|
|
1210
1215
|
modelId: this.modelId
|
|
1211
1216
|
}),
|
|
1212
|
-
headers: (0,
|
|
1217
|
+
headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
|
|
1213
1218
|
body: args,
|
|
1214
1219
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1215
|
-
successfulResponseHandler: (0,
|
|
1220
|
+
successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
|
|
1216
1221
|
openaiCompletionResponseSchema
|
|
1217
1222
|
),
|
|
1218
1223
|
abortSignal: options.abortSignal,
|
|
@@ -1243,15 +1248,15 @@ var OpenAICompletionLanguageModel = class {
|
|
|
1243
1248
|
// only include stream_options when in strict compatibility mode:
|
|
1244
1249
|
stream_options: this.config.compatibility === "strict" ? { include_usage: true } : void 0
|
|
1245
1250
|
};
|
|
1246
|
-
const { responseHeaders, value: response } = await (0,
|
|
1251
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({
|
|
1247
1252
|
url: this.config.url({
|
|
1248
1253
|
path: "/completions",
|
|
1249
1254
|
modelId: this.modelId
|
|
1250
1255
|
}),
|
|
1251
|
-
headers: (0,
|
|
1256
|
+
headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
|
|
1252
1257
|
body,
|
|
1253
1258
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1254
|
-
successfulResponseHandler: (0,
|
|
1259
|
+
successfulResponseHandler: (0, import_provider_utils3.createEventSourceResponseHandler)(
|
|
1255
1260
|
openaiCompletionChunkSchema
|
|
1256
1261
|
),
|
|
1257
1262
|
abortSignal: options.abortSignal,
|
|
@@ -1375,7 +1380,7 @@ var openaiCompletionChunkSchema = import_zod3.z.union([
|
|
|
1375
1380
|
|
|
1376
1381
|
// src/openai-embedding-model.ts
|
|
1377
1382
|
var import_provider5 = require("@ai-sdk/provider");
|
|
1378
|
-
var
|
|
1383
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
1379
1384
|
var import_zod4 = require("zod");
|
|
1380
1385
|
var OpenAIEmbeddingModel = class {
|
|
1381
1386
|
constructor(modelId, settings, config) {
|
|
@@ -1408,12 +1413,12 @@ var OpenAIEmbeddingModel = class {
|
|
|
1408
1413
|
values
|
|
1409
1414
|
});
|
|
1410
1415
|
}
|
|
1411
|
-
const { responseHeaders, value: response } = await (0,
|
|
1416
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
|
|
1412
1417
|
url: this.config.url({
|
|
1413
1418
|
path: "/embeddings",
|
|
1414
1419
|
modelId: this.modelId
|
|
1415
1420
|
}),
|
|
1416
|
-
headers: (0,
|
|
1421
|
+
headers: (0, import_provider_utils4.combineHeaders)(this.config.headers(), headers),
|
|
1417
1422
|
body: {
|
|
1418
1423
|
model: this.modelId,
|
|
1419
1424
|
input: values,
|
|
@@ -1422,7 +1427,7 @@ var OpenAIEmbeddingModel = class {
|
|
|
1422
1427
|
user: this.settings.user
|
|
1423
1428
|
},
|
|
1424
1429
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1425
|
-
successfulResponseHandler: (0,
|
|
1430
|
+
successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
|
|
1426
1431
|
openaiTextEmbeddingResponseSchema
|
|
1427
1432
|
),
|
|
1428
1433
|
abortSignal,
|
|
@@ -1441,7 +1446,7 @@ var openaiTextEmbeddingResponseSchema = import_zod4.z.object({
|
|
|
1441
1446
|
});
|
|
1442
1447
|
|
|
1443
1448
|
// src/openai-image-model.ts
|
|
1444
|
-
var
|
|
1449
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
1445
1450
|
var import_zod5 = require("zod");
|
|
1446
1451
|
|
|
1447
1452
|
// src/openai-image-settings.ts
|
|
@@ -1488,12 +1493,12 @@ var OpenAIImageModel = class {
|
|
|
1488
1493
|
warnings.push({ type: "unsupported-setting", setting: "seed" });
|
|
1489
1494
|
}
|
|
1490
1495
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1491
|
-
const { value: response, responseHeaders } = await (0,
|
|
1496
|
+
const { value: response, responseHeaders } = await (0, import_provider_utils5.postJsonToApi)({
|
|
1492
1497
|
url: this.config.url({
|
|
1493
1498
|
path: "/images/generations",
|
|
1494
1499
|
modelId: this.modelId
|
|
1495
1500
|
}),
|
|
1496
|
-
headers: (0,
|
|
1501
|
+
headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), headers),
|
|
1497
1502
|
body: {
|
|
1498
1503
|
model: this.modelId,
|
|
1499
1504
|
prompt,
|
|
@@ -1503,7 +1508,7 @@ var OpenAIImageModel = class {
|
|
|
1503
1508
|
response_format: "b64_json"
|
|
1504
1509
|
},
|
|
1505
1510
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1506
|
-
successfulResponseHandler: (0,
|
|
1511
|
+
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
|
|
1507
1512
|
openaiImageResponseSchema
|
|
1508
1513
|
),
|
|
1509
1514
|
abortSignal,
|
|
@@ -1524,13 +1529,186 @@ var openaiImageResponseSchema = import_zod5.z.object({
|
|
|
1524
1529
|
data: import_zod5.z.array(import_zod5.z.object({ b64_json: import_zod5.z.string() }))
|
|
1525
1530
|
});
|
|
1526
1531
|
|
|
1527
|
-
// src/
|
|
1528
|
-
var
|
|
1532
|
+
// src/openai-transcription-model.ts
|
|
1533
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1529
1534
|
var import_zod6 = require("zod");
|
|
1535
|
+
var OpenAIProviderOptionsSchema = import_zod6.z.object({
|
|
1536
|
+
include: import_zod6.z.array(import_zod6.z.string()).optional().describe(
|
|
1537
|
+
"Additional information to include in the transcription response."
|
|
1538
|
+
),
|
|
1539
|
+
language: import_zod6.z.string().optional().describe("The language of the input audio in ISO-639-1 format."),
|
|
1540
|
+
prompt: import_zod6.z.string().optional().describe(
|
|
1541
|
+
"An optional text to guide the model's style or continue a previous audio segment."
|
|
1542
|
+
),
|
|
1543
|
+
temperature: import_zod6.z.number().min(0).max(1).optional().default(0).describe("The sampling temperature, between 0 and 1."),
|
|
1544
|
+
timestampGranularities: import_zod6.z.array(import_zod6.z.enum(["word", "segment"])).optional().default(["segment"]).describe(
|
|
1545
|
+
"The timestamp granularities to populate for this transcription."
|
|
1546
|
+
)
|
|
1547
|
+
});
|
|
1548
|
+
var languageMap = {
|
|
1549
|
+
afrikaans: "af",
|
|
1550
|
+
arabic: "ar",
|
|
1551
|
+
armenian: "hy",
|
|
1552
|
+
azerbaijani: "az",
|
|
1553
|
+
belarusian: "be",
|
|
1554
|
+
bosnian: "bs",
|
|
1555
|
+
bulgarian: "bg",
|
|
1556
|
+
catalan: "ca",
|
|
1557
|
+
chinese: "zh",
|
|
1558
|
+
croatian: "hr",
|
|
1559
|
+
czech: "cs",
|
|
1560
|
+
danish: "da",
|
|
1561
|
+
dutch: "nl",
|
|
1562
|
+
english: "en",
|
|
1563
|
+
estonian: "et",
|
|
1564
|
+
finnish: "fi",
|
|
1565
|
+
french: "fr",
|
|
1566
|
+
galician: "gl",
|
|
1567
|
+
german: "de",
|
|
1568
|
+
greek: "el",
|
|
1569
|
+
hebrew: "he",
|
|
1570
|
+
hindi: "hi",
|
|
1571
|
+
hungarian: "hu",
|
|
1572
|
+
icelandic: "is",
|
|
1573
|
+
indonesian: "id",
|
|
1574
|
+
italian: "it",
|
|
1575
|
+
japanese: "ja",
|
|
1576
|
+
kannada: "kn",
|
|
1577
|
+
kazakh: "kk",
|
|
1578
|
+
korean: "ko",
|
|
1579
|
+
latvian: "lv",
|
|
1580
|
+
lithuanian: "lt",
|
|
1581
|
+
macedonian: "mk",
|
|
1582
|
+
malay: "ms",
|
|
1583
|
+
marathi: "mr",
|
|
1584
|
+
maori: "mi",
|
|
1585
|
+
nepali: "ne",
|
|
1586
|
+
norwegian: "no",
|
|
1587
|
+
persian: "fa",
|
|
1588
|
+
polish: "pl",
|
|
1589
|
+
portuguese: "pt",
|
|
1590
|
+
romanian: "ro",
|
|
1591
|
+
russian: "ru",
|
|
1592
|
+
serbian: "sr",
|
|
1593
|
+
slovak: "sk",
|
|
1594
|
+
slovenian: "sl",
|
|
1595
|
+
spanish: "es",
|
|
1596
|
+
swahili: "sw",
|
|
1597
|
+
swedish: "sv",
|
|
1598
|
+
tagalog: "tl",
|
|
1599
|
+
tamil: "ta",
|
|
1600
|
+
thai: "th",
|
|
1601
|
+
turkish: "tr",
|
|
1602
|
+
ukrainian: "uk",
|
|
1603
|
+
urdu: "ur",
|
|
1604
|
+
vietnamese: "vi",
|
|
1605
|
+
welsh: "cy"
|
|
1606
|
+
};
|
|
1607
|
+
var OpenAITranscriptionModel = class {
|
|
1608
|
+
constructor(modelId, config) {
|
|
1609
|
+
this.modelId = modelId;
|
|
1610
|
+
this.config = config;
|
|
1611
|
+
this.specificationVersion = "v1";
|
|
1612
|
+
}
|
|
1613
|
+
get provider() {
|
|
1614
|
+
return this.config.provider;
|
|
1615
|
+
}
|
|
1616
|
+
getArgs({
|
|
1617
|
+
audio,
|
|
1618
|
+
mediaType,
|
|
1619
|
+
providerOptions
|
|
1620
|
+
}) {
|
|
1621
|
+
const warnings = [];
|
|
1622
|
+
const openAIOptions = (0, import_provider_utils6.parseProviderOptions)({
|
|
1623
|
+
provider: "openai",
|
|
1624
|
+
providerOptions,
|
|
1625
|
+
schema: OpenAIProviderOptionsSchema
|
|
1626
|
+
});
|
|
1627
|
+
const formData = new FormData();
|
|
1628
|
+
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils6.convertBase64ToUint8Array)(audio)]);
|
|
1629
|
+
formData.append("model", this.modelId);
|
|
1630
|
+
formData.append("file", new File([blob], "audio", { type: mediaType }));
|
|
1631
|
+
if (openAIOptions) {
|
|
1632
|
+
const transcriptionModelOptions = {
|
|
1633
|
+
include: openAIOptions.include,
|
|
1634
|
+
language: openAIOptions.language,
|
|
1635
|
+
prompt: openAIOptions.prompt,
|
|
1636
|
+
temperature: openAIOptions.temperature,
|
|
1637
|
+
timestamp_granularities: openAIOptions.timestampGranularities
|
|
1638
|
+
};
|
|
1639
|
+
for (const key in transcriptionModelOptions) {
|
|
1640
|
+
const value = transcriptionModelOptions[key];
|
|
1641
|
+
if (value !== void 0) {
|
|
1642
|
+
formData.append(key, value);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
return {
|
|
1647
|
+
formData,
|
|
1648
|
+
warnings
|
|
1649
|
+
};
|
|
1650
|
+
}
|
|
1651
|
+
async doGenerate(options) {
|
|
1652
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1653
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1654
|
+
const { formData, warnings } = this.getArgs(options);
|
|
1655
|
+
const {
|
|
1656
|
+
value: response,
|
|
1657
|
+
responseHeaders,
|
|
1658
|
+
rawValue: rawResponse
|
|
1659
|
+
} = await (0, import_provider_utils6.postFormDataToApi)({
|
|
1660
|
+
url: this.config.url({
|
|
1661
|
+
path: "/audio/transcriptions",
|
|
1662
|
+
modelId: this.modelId
|
|
1663
|
+
}),
|
|
1664
|
+
headers: (0, import_provider_utils6.combineHeaders)(this.config.headers(), options.headers),
|
|
1665
|
+
formData,
|
|
1666
|
+
failedResponseHandler: openaiFailedResponseHandler,
|
|
1667
|
+
successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
|
|
1668
|
+
openaiTranscriptionResponseSchema
|
|
1669
|
+
),
|
|
1670
|
+
abortSignal: options.abortSignal,
|
|
1671
|
+
fetch: this.config.fetch
|
|
1672
|
+
});
|
|
1673
|
+
const language = response.language != null && response.language in languageMap ? languageMap[response.language] : void 0;
|
|
1674
|
+
return {
|
|
1675
|
+
text: response.text,
|
|
1676
|
+
segments: (_e = (_d = response.words) == null ? void 0 : _d.map((word) => ({
|
|
1677
|
+
text: word.word,
|
|
1678
|
+
startSecond: word.start,
|
|
1679
|
+
endSecond: word.end
|
|
1680
|
+
}))) != null ? _e : [],
|
|
1681
|
+
language,
|
|
1682
|
+
durationInSeconds: (_f = response.duration) != null ? _f : void 0,
|
|
1683
|
+
warnings,
|
|
1684
|
+
response: {
|
|
1685
|
+
timestamp: currentDate,
|
|
1686
|
+
modelId: this.modelId,
|
|
1687
|
+
headers: responseHeaders,
|
|
1688
|
+
body: rawResponse
|
|
1689
|
+
}
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
};
|
|
1693
|
+
var openaiTranscriptionResponseSchema = import_zod6.z.object({
|
|
1694
|
+
text: import_zod6.z.string(),
|
|
1695
|
+
language: import_zod6.z.string().nullish(),
|
|
1696
|
+
duration: import_zod6.z.number().nullish(),
|
|
1697
|
+
words: import_zod6.z.array(
|
|
1698
|
+
import_zod6.z.object({
|
|
1699
|
+
word: import_zod6.z.string(),
|
|
1700
|
+
start: import_zod6.z.number(),
|
|
1701
|
+
end: import_zod6.z.number()
|
|
1702
|
+
})
|
|
1703
|
+
).nullish()
|
|
1704
|
+
});
|
|
1705
|
+
|
|
1706
|
+
// src/responses/openai-responses-language-model.ts
|
|
1707
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1708
|
+
var import_zod7 = require("zod");
|
|
1530
1709
|
|
|
1531
1710
|
// src/responses/convert-to-openai-responses-messages.ts
|
|
1532
1711
|
var import_provider6 = require("@ai-sdk/provider");
|
|
1533
|
-
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1534
1712
|
function convertToOpenAIResponsesMessages({
|
|
1535
1713
|
prompt,
|
|
1536
1714
|
systemMessageMode
|
|
@@ -1569,38 +1747,35 @@ function convertToOpenAIResponsesMessages({
|
|
|
1569
1747
|
messages.push({
|
|
1570
1748
|
role: "user",
|
|
1571
1749
|
content: content.map((part, index) => {
|
|
1572
|
-
var _a, _b, _c
|
|
1750
|
+
var _a, _b, _c;
|
|
1573
1751
|
switch (part.type) {
|
|
1574
1752
|
case "text": {
|
|
1575
1753
|
return { type: "input_text", text: part.text };
|
|
1576
1754
|
}
|
|
1577
|
-
case "image": {
|
|
1578
|
-
return {
|
|
1579
|
-
type: "input_image",
|
|
1580
|
-
image_url: part.image instanceof URL ? part.image.toString() : `data:${(_a = part.mimeType) != null ? _a : "image/jpeg"};base64,${(0, import_provider_utils7.convertUint8ArrayToBase64)(part.image)}`,
|
|
1581
|
-
// OpenAI specific extension: image detail
|
|
1582
|
-
detail: (_c = (_b = part.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.imageDetail
|
|
1583
|
-
};
|
|
1584
|
-
}
|
|
1585
1755
|
case "file": {
|
|
1586
|
-
if (part.
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
file_data: `data:application/pdf;base64,${part.data}`
|
|
1597
|
-
};
|
|
1598
|
-
}
|
|
1599
|
-
default: {
|
|
1756
|
+
if (part.mediaType.startsWith("image/")) {
|
|
1757
|
+
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
1758
|
+
return {
|
|
1759
|
+
type: "input_image",
|
|
1760
|
+
image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`,
|
|
1761
|
+
// OpenAI specific extension: image detail
|
|
1762
|
+
detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
|
|
1763
|
+
};
|
|
1764
|
+
} else if (part.mediaType === "application/pdf") {
|
|
1765
|
+
if (part.data instanceof URL) {
|
|
1600
1766
|
throw new import_provider6.UnsupportedFunctionalityError({
|
|
1601
|
-
functionality: "
|
|
1767
|
+
functionality: "PDF file parts with URLs"
|
|
1602
1768
|
});
|
|
1603
1769
|
}
|
|
1770
|
+
return {
|
|
1771
|
+
type: "input_file",
|
|
1772
|
+
filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
|
|
1773
|
+
file_data: `data:application/pdf;base64,${part.data}`
|
|
1774
|
+
};
|
|
1775
|
+
} else {
|
|
1776
|
+
throw new import_provider6.UnsupportedFunctionalityError({
|
|
1777
|
+
functionality: `file part media type ${part.mediaType}`
|
|
1778
|
+
});
|
|
1604
1779
|
}
|
|
1605
1780
|
}
|
|
1606
1781
|
}
|
|
@@ -1729,7 +1904,7 @@ function prepareResponsesTools({
|
|
|
1729
1904
|
default: {
|
|
1730
1905
|
const _exhaustiveCheck = type;
|
|
1731
1906
|
throw new import_provider7.UnsupportedFunctionalityError({
|
|
1732
|
-
functionality: `
|
|
1907
|
+
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
1733
1908
|
});
|
|
1734
1909
|
}
|
|
1735
1910
|
}
|
|
@@ -1790,7 +1965,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1790
1965
|
systemMessageMode: modelConfig.systemMessageMode
|
|
1791
1966
|
});
|
|
1792
1967
|
warnings.push(...messageWarnings);
|
|
1793
|
-
const openaiOptions = (0,
|
|
1968
|
+
const openaiOptions = (0, import_provider_utils7.parseProviderOptions)({
|
|
1794
1969
|
provider: "openai",
|
|
1795
1970
|
providerOptions,
|
|
1796
1971
|
schema: openaiResponsesProviderOptionsSchema
|
|
@@ -1871,58 +2046,58 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1871
2046
|
responseHeaders,
|
|
1872
2047
|
value: response,
|
|
1873
2048
|
rawValue: rawResponse
|
|
1874
|
-
} = await (0,
|
|
2049
|
+
} = await (0, import_provider_utils7.postJsonToApi)({
|
|
1875
2050
|
url: this.config.url({
|
|
1876
2051
|
path: "/responses",
|
|
1877
2052
|
modelId: this.modelId
|
|
1878
2053
|
}),
|
|
1879
|
-
headers: (0,
|
|
2054
|
+
headers: (0, import_provider_utils7.combineHeaders)(this.config.headers(), options.headers),
|
|
1880
2055
|
body,
|
|
1881
2056
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1882
|
-
successfulResponseHandler: (0,
|
|
1883
|
-
|
|
1884
|
-
id:
|
|
1885
|
-
created_at:
|
|
1886
|
-
model:
|
|
1887
|
-
output:
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
type:
|
|
1891
|
-
role:
|
|
1892
|
-
content:
|
|
1893
|
-
|
|
1894
|
-
type:
|
|
1895
|
-
text:
|
|
1896
|
-
annotations:
|
|
1897
|
-
|
|
1898
|
-
type:
|
|
1899
|
-
start_index:
|
|
1900
|
-
end_index:
|
|
1901
|
-
url:
|
|
1902
|
-
title:
|
|
2057
|
+
successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
|
|
2058
|
+
import_zod7.z.object({
|
|
2059
|
+
id: import_zod7.z.string(),
|
|
2060
|
+
created_at: import_zod7.z.number(),
|
|
2061
|
+
model: import_zod7.z.string(),
|
|
2062
|
+
output: import_zod7.z.array(
|
|
2063
|
+
import_zod7.z.discriminatedUnion("type", [
|
|
2064
|
+
import_zod7.z.object({
|
|
2065
|
+
type: import_zod7.z.literal("message"),
|
|
2066
|
+
role: import_zod7.z.literal("assistant"),
|
|
2067
|
+
content: import_zod7.z.array(
|
|
2068
|
+
import_zod7.z.object({
|
|
2069
|
+
type: import_zod7.z.literal("output_text"),
|
|
2070
|
+
text: import_zod7.z.string(),
|
|
2071
|
+
annotations: import_zod7.z.array(
|
|
2072
|
+
import_zod7.z.object({
|
|
2073
|
+
type: import_zod7.z.literal("url_citation"),
|
|
2074
|
+
start_index: import_zod7.z.number(),
|
|
2075
|
+
end_index: import_zod7.z.number(),
|
|
2076
|
+
url: import_zod7.z.string(),
|
|
2077
|
+
title: import_zod7.z.string()
|
|
1903
2078
|
})
|
|
1904
2079
|
)
|
|
1905
2080
|
})
|
|
1906
2081
|
)
|
|
1907
2082
|
}),
|
|
1908
|
-
|
|
1909
|
-
type:
|
|
1910
|
-
call_id:
|
|
1911
|
-
name:
|
|
1912
|
-
arguments:
|
|
2083
|
+
import_zod7.z.object({
|
|
2084
|
+
type: import_zod7.z.literal("function_call"),
|
|
2085
|
+
call_id: import_zod7.z.string(),
|
|
2086
|
+
name: import_zod7.z.string(),
|
|
2087
|
+
arguments: import_zod7.z.string()
|
|
1913
2088
|
}),
|
|
1914
|
-
|
|
1915
|
-
type:
|
|
2089
|
+
import_zod7.z.object({
|
|
2090
|
+
type: import_zod7.z.literal("web_search_call")
|
|
1916
2091
|
}),
|
|
1917
|
-
|
|
1918
|
-
type:
|
|
2092
|
+
import_zod7.z.object({
|
|
2093
|
+
type: import_zod7.z.literal("computer_call")
|
|
1919
2094
|
}),
|
|
1920
|
-
|
|
1921
|
-
type:
|
|
2095
|
+
import_zod7.z.object({
|
|
2096
|
+
type: import_zod7.z.literal("reasoning")
|
|
1922
2097
|
})
|
|
1923
2098
|
])
|
|
1924
2099
|
),
|
|
1925
|
-
incomplete_details:
|
|
2100
|
+
incomplete_details: import_zod7.z.object({ reason: import_zod7.z.string() }).nullable(),
|
|
1926
2101
|
usage: usageSchema
|
|
1927
2102
|
})
|
|
1928
2103
|
),
|
|
@@ -1943,7 +2118,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1943
2118
|
var _a2, _b2, _c2;
|
|
1944
2119
|
return {
|
|
1945
2120
|
sourceType: "url",
|
|
1946
|
-
id: (_c2 = (_b2 = (_a2 = this.config).generateId) == null ? void 0 : _b2.call(_a2)) != null ? _c2 : (0,
|
|
2121
|
+
id: (_c2 = (_b2 = (_a2 = this.config).generateId) == null ? void 0 : _b2.call(_a2)) != null ? _c2 : (0, import_provider_utils7.generateId)(),
|
|
1947
2122
|
url: annotation.url,
|
|
1948
2123
|
title: annotation.title
|
|
1949
2124
|
};
|
|
@@ -1986,18 +2161,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
1986
2161
|
}
|
|
1987
2162
|
async doStream(options) {
|
|
1988
2163
|
const { args: body, warnings } = this.getArgs(options);
|
|
1989
|
-
const { responseHeaders, value: response } = await (0,
|
|
2164
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils7.postJsonToApi)({
|
|
1990
2165
|
url: this.config.url({
|
|
1991
2166
|
path: "/responses",
|
|
1992
2167
|
modelId: this.modelId
|
|
1993
2168
|
}),
|
|
1994
|
-
headers: (0,
|
|
2169
|
+
headers: (0, import_provider_utils7.combineHeaders)(this.config.headers(), options.headers),
|
|
1995
2170
|
body: {
|
|
1996
2171
|
...body,
|
|
1997
2172
|
stream: true
|
|
1998
2173
|
},
|
|
1999
2174
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2000
|
-
successfulResponseHandler: (0,
|
|
2175
|
+
successfulResponseHandler: (0, import_provider_utils7.createEventSourceResponseHandler)(
|
|
2001
2176
|
openaiResponsesChunkSchema
|
|
2002
2177
|
),
|
|
2003
2178
|
abortSignal: options.abortSignal,
|
|
@@ -2085,7 +2260,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2085
2260
|
type: "source",
|
|
2086
2261
|
source: {
|
|
2087
2262
|
sourceType: "url",
|
|
2088
|
-
id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : (0,
|
|
2263
|
+
id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : (0, import_provider_utils7.generateId)(),
|
|
2089
2264
|
url: value.annotation.url,
|
|
2090
2265
|
title: value.annotation.title
|
|
2091
2266
|
}
|
|
@@ -2120,79 +2295,79 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2120
2295
|
};
|
|
2121
2296
|
}
|
|
2122
2297
|
};
|
|
2123
|
-
var usageSchema =
|
|
2124
|
-
input_tokens:
|
|
2125
|
-
input_tokens_details:
|
|
2126
|
-
output_tokens:
|
|
2127
|
-
output_tokens_details:
|
|
2298
|
+
var usageSchema = import_zod7.z.object({
|
|
2299
|
+
input_tokens: import_zod7.z.number(),
|
|
2300
|
+
input_tokens_details: import_zod7.z.object({ cached_tokens: import_zod7.z.number().nullish() }).nullish(),
|
|
2301
|
+
output_tokens: import_zod7.z.number(),
|
|
2302
|
+
output_tokens_details: import_zod7.z.object({ reasoning_tokens: import_zod7.z.number().nullish() }).nullish()
|
|
2128
2303
|
});
|
|
2129
|
-
var textDeltaChunkSchema =
|
|
2130
|
-
type:
|
|
2131
|
-
delta:
|
|
2304
|
+
var textDeltaChunkSchema = import_zod7.z.object({
|
|
2305
|
+
type: import_zod7.z.literal("response.output_text.delta"),
|
|
2306
|
+
delta: import_zod7.z.string()
|
|
2132
2307
|
});
|
|
2133
|
-
var responseFinishedChunkSchema =
|
|
2134
|
-
type:
|
|
2135
|
-
response:
|
|
2136
|
-
incomplete_details:
|
|
2308
|
+
var responseFinishedChunkSchema = import_zod7.z.object({
|
|
2309
|
+
type: import_zod7.z.enum(["response.completed", "response.incomplete"]),
|
|
2310
|
+
response: import_zod7.z.object({
|
|
2311
|
+
incomplete_details: import_zod7.z.object({ reason: import_zod7.z.string() }).nullish(),
|
|
2137
2312
|
usage: usageSchema
|
|
2138
2313
|
})
|
|
2139
2314
|
});
|
|
2140
|
-
var responseCreatedChunkSchema =
|
|
2141
|
-
type:
|
|
2142
|
-
response:
|
|
2143
|
-
id:
|
|
2144
|
-
created_at:
|
|
2145
|
-
model:
|
|
2315
|
+
var responseCreatedChunkSchema = import_zod7.z.object({
|
|
2316
|
+
type: import_zod7.z.literal("response.created"),
|
|
2317
|
+
response: import_zod7.z.object({
|
|
2318
|
+
id: import_zod7.z.string(),
|
|
2319
|
+
created_at: import_zod7.z.number(),
|
|
2320
|
+
model: import_zod7.z.string()
|
|
2146
2321
|
})
|
|
2147
2322
|
});
|
|
2148
|
-
var responseOutputItemDoneSchema =
|
|
2149
|
-
type:
|
|
2150
|
-
output_index:
|
|
2151
|
-
item:
|
|
2152
|
-
|
|
2153
|
-
type:
|
|
2323
|
+
var responseOutputItemDoneSchema = import_zod7.z.object({
|
|
2324
|
+
type: import_zod7.z.literal("response.output_item.done"),
|
|
2325
|
+
output_index: import_zod7.z.number(),
|
|
2326
|
+
item: import_zod7.z.discriminatedUnion("type", [
|
|
2327
|
+
import_zod7.z.object({
|
|
2328
|
+
type: import_zod7.z.literal("message")
|
|
2154
2329
|
}),
|
|
2155
|
-
|
|
2156
|
-
type:
|
|
2157
|
-
id:
|
|
2158
|
-
call_id:
|
|
2159
|
-
name:
|
|
2160
|
-
arguments:
|
|
2161
|
-
status:
|
|
2330
|
+
import_zod7.z.object({
|
|
2331
|
+
type: import_zod7.z.literal("function_call"),
|
|
2332
|
+
id: import_zod7.z.string(),
|
|
2333
|
+
call_id: import_zod7.z.string(),
|
|
2334
|
+
name: import_zod7.z.string(),
|
|
2335
|
+
arguments: import_zod7.z.string(),
|
|
2336
|
+
status: import_zod7.z.literal("completed")
|
|
2162
2337
|
})
|
|
2163
2338
|
])
|
|
2164
2339
|
});
|
|
2165
|
-
var responseFunctionCallArgumentsDeltaSchema =
|
|
2166
|
-
type:
|
|
2167
|
-
item_id:
|
|
2168
|
-
output_index:
|
|
2169
|
-
delta:
|
|
2340
|
+
var responseFunctionCallArgumentsDeltaSchema = import_zod7.z.object({
|
|
2341
|
+
type: import_zod7.z.literal("response.function_call_arguments.delta"),
|
|
2342
|
+
item_id: import_zod7.z.string(),
|
|
2343
|
+
output_index: import_zod7.z.number(),
|
|
2344
|
+
delta: import_zod7.z.string()
|
|
2170
2345
|
});
|
|
2171
|
-
var responseOutputItemAddedSchema =
|
|
2172
|
-
type:
|
|
2173
|
-
output_index:
|
|
2174
|
-
item:
|
|
2175
|
-
|
|
2176
|
-
type:
|
|
2346
|
+
var responseOutputItemAddedSchema = import_zod7.z.object({
|
|
2347
|
+
type: import_zod7.z.literal("response.output_item.added"),
|
|
2348
|
+
output_index: import_zod7.z.number(),
|
|
2349
|
+
item: import_zod7.z.discriminatedUnion("type", [
|
|
2350
|
+
import_zod7.z.object({
|
|
2351
|
+
type: import_zod7.z.literal("message")
|
|
2177
2352
|
}),
|
|
2178
|
-
|
|
2179
|
-
type:
|
|
2180
|
-
id:
|
|
2181
|
-
call_id:
|
|
2182
|
-
name:
|
|
2183
|
-
arguments:
|
|
2353
|
+
import_zod7.z.object({
|
|
2354
|
+
type: import_zod7.z.literal("function_call"),
|
|
2355
|
+
id: import_zod7.z.string(),
|
|
2356
|
+
call_id: import_zod7.z.string(),
|
|
2357
|
+
name: import_zod7.z.string(),
|
|
2358
|
+
arguments: import_zod7.z.string()
|
|
2184
2359
|
})
|
|
2185
2360
|
])
|
|
2186
2361
|
});
|
|
2187
|
-
var responseAnnotationAddedSchema =
|
|
2188
|
-
type:
|
|
2189
|
-
annotation:
|
|
2190
|
-
type:
|
|
2191
|
-
url:
|
|
2192
|
-
title:
|
|
2362
|
+
var responseAnnotationAddedSchema = import_zod7.z.object({
|
|
2363
|
+
type: import_zod7.z.literal("response.output_text.annotation.added"),
|
|
2364
|
+
annotation: import_zod7.z.object({
|
|
2365
|
+
type: import_zod7.z.literal("url_citation"),
|
|
2366
|
+
url: import_zod7.z.string(),
|
|
2367
|
+
title: import_zod7.z.string()
|
|
2193
2368
|
})
|
|
2194
2369
|
});
|
|
2195
|
-
var openaiResponsesChunkSchema =
|
|
2370
|
+
var openaiResponsesChunkSchema = import_zod7.z.union([
|
|
2196
2371
|
textDeltaChunkSchema,
|
|
2197
2372
|
responseFinishedChunkSchema,
|
|
2198
2373
|
responseCreatedChunkSchema,
|
|
@@ -2200,7 +2375,7 @@ var openaiResponsesChunkSchema = import_zod6.z.union([
|
|
|
2200
2375
|
responseFunctionCallArgumentsDeltaSchema,
|
|
2201
2376
|
responseOutputItemAddedSchema,
|
|
2202
2377
|
responseAnnotationAddedSchema,
|
|
2203
|
-
|
|
2378
|
+
import_zod7.z.object({ type: import_zod7.z.string() }).passthrough()
|
|
2204
2379
|
// fallback for unknown chunks
|
|
2205
2380
|
]);
|
|
2206
2381
|
function isTextDeltaChunk(chunk) {
|
|
@@ -2245,15 +2420,15 @@ function getResponsesModelConfig(modelId) {
|
|
|
2245
2420
|
requiredAutoTruncation: false
|
|
2246
2421
|
};
|
|
2247
2422
|
}
|
|
2248
|
-
var openaiResponsesProviderOptionsSchema =
|
|
2249
|
-
metadata:
|
|
2250
|
-
parallelToolCalls:
|
|
2251
|
-
previousResponseId:
|
|
2252
|
-
store:
|
|
2253
|
-
user:
|
|
2254
|
-
reasoningEffort:
|
|
2255
|
-
strictSchemas:
|
|
2256
|
-
instructions:
|
|
2423
|
+
var openaiResponsesProviderOptionsSchema = import_zod7.z.object({
|
|
2424
|
+
metadata: import_zod7.z.any().nullish(),
|
|
2425
|
+
parallelToolCalls: import_zod7.z.boolean().nullish(),
|
|
2426
|
+
previousResponseId: import_zod7.z.string().nullish(),
|
|
2427
|
+
store: import_zod7.z.boolean().nullish(),
|
|
2428
|
+
user: import_zod7.z.string().nullish(),
|
|
2429
|
+
reasoningEffort: import_zod7.z.string().nullish(),
|
|
2430
|
+
strictSchemas: import_zod7.z.boolean().nullish(),
|
|
2431
|
+
instructions: import_zod7.z.string().nullish()
|
|
2257
2432
|
});
|
|
2258
2433
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2259
2434
|
0 && (module.exports = {
|
|
@@ -2262,6 +2437,7 @@ var openaiResponsesProviderOptionsSchema = import_zod6.z.object({
|
|
|
2262
2437
|
OpenAIEmbeddingModel,
|
|
2263
2438
|
OpenAIImageModel,
|
|
2264
2439
|
OpenAIResponsesLanguageModel,
|
|
2440
|
+
OpenAITranscriptionModel,
|
|
2265
2441
|
modelMaxImagesPerCall
|
|
2266
2442
|
});
|
|
2267
2443
|
//# sourceMappingURL=index.js.map
|