@ai-sdk/openai 2.1.0-beta.9 → 3.0.0-beta.17
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 +67 -0
- package/dist/index.d.mts +16 -10
- package/dist/index.d.ts +16 -10
- package/dist/index.js +61 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -19
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +115 -11
- package/dist/internal/index.d.ts +115 -11
- package/dist/internal/index.js +59 -13
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +56 -13
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/internal/index.mjs
CHANGED
|
@@ -41,6 +41,7 @@ function convertToOpenAIChatMessages({
|
|
|
41
41
|
prompt,
|
|
42
42
|
systemMessageMode = "system"
|
|
43
43
|
}) {
|
|
44
|
+
var _a;
|
|
44
45
|
const messages = [];
|
|
45
46
|
const warnings = [];
|
|
46
47
|
for (const { role, content } of prompt) {
|
|
@@ -79,7 +80,7 @@ function convertToOpenAIChatMessages({
|
|
|
79
80
|
messages.push({
|
|
80
81
|
role: "user",
|
|
81
82
|
content: content.map((part, index) => {
|
|
82
|
-
var
|
|
83
|
+
var _a2, _b, _c;
|
|
83
84
|
switch (part.type) {
|
|
84
85
|
case "text": {
|
|
85
86
|
return { type: "text", text: part.text };
|
|
@@ -92,7 +93,7 @@ function convertToOpenAIChatMessages({
|
|
|
92
93
|
image_url: {
|
|
93
94
|
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
|
|
94
95
|
// OpenAI specific extension: image detail
|
|
95
|
-
detail: (_b = (
|
|
96
|
+
detail: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.imageDetail
|
|
96
97
|
}
|
|
97
98
|
};
|
|
98
99
|
} else if (part.mediaType.startsWith("audio/")) {
|
|
@@ -189,6 +190,9 @@ function convertToOpenAIChatMessages({
|
|
|
189
190
|
case "error-text":
|
|
190
191
|
contentValue = output.value;
|
|
191
192
|
break;
|
|
193
|
+
case "execution-denied":
|
|
194
|
+
contentValue = (_a = output.reason) != null ? _a : "Tool execution denied.";
|
|
195
|
+
break;
|
|
192
196
|
case "content":
|
|
193
197
|
case "json":
|
|
194
198
|
case "error-json":
|
|
@@ -1593,9 +1597,13 @@ import { z as z8 } from "zod/v4";
|
|
|
1593
1597
|
var modelMaxImagesPerCall = {
|
|
1594
1598
|
"dall-e-3": 1,
|
|
1595
1599
|
"dall-e-2": 10,
|
|
1596
|
-
"gpt-image-1": 10
|
|
1600
|
+
"gpt-image-1": 10,
|
|
1601
|
+
"gpt-image-1-mini": 10
|
|
1597
1602
|
};
|
|
1598
|
-
var hasDefaultResponseFormat = /* @__PURE__ */ new Set([
|
|
1603
|
+
var hasDefaultResponseFormat = /* @__PURE__ */ new Set([
|
|
1604
|
+
"gpt-image-1",
|
|
1605
|
+
"gpt-image-1-mini"
|
|
1606
|
+
]);
|
|
1599
1607
|
|
|
1600
1608
|
// src/image/openai-image-model.ts
|
|
1601
1609
|
var OpenAIImageModel = class {
|
|
@@ -1783,7 +1791,7 @@ var OpenAITranscriptionModel = class {
|
|
|
1783
1791
|
constructor(modelId, config) {
|
|
1784
1792
|
this.modelId = modelId;
|
|
1785
1793
|
this.config = config;
|
|
1786
|
-
this.specificationVersion = "
|
|
1794
|
+
this.specificationVersion = "v3";
|
|
1787
1795
|
}
|
|
1788
1796
|
get provider() {
|
|
1789
1797
|
return this.config.provider;
|
|
@@ -1928,7 +1936,7 @@ var OpenAISpeechModel = class {
|
|
|
1928
1936
|
constructor(modelId, config) {
|
|
1929
1937
|
this.modelId = modelId;
|
|
1930
1938
|
this.config = config;
|
|
1931
|
-
this.specificationVersion = "
|
|
1939
|
+
this.specificationVersion = "v3";
|
|
1932
1940
|
}
|
|
1933
1941
|
get provider() {
|
|
1934
1942
|
return this.config.provider;
|
|
@@ -2080,7 +2088,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2080
2088
|
store,
|
|
2081
2089
|
hasLocalShellTool = false
|
|
2082
2090
|
}) {
|
|
2083
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2091
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2084
2092
|
const input = [];
|
|
2085
2093
|
const warnings = [];
|
|
2086
2094
|
for (const { role, content } of prompt) {
|
|
@@ -2283,6 +2291,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2283
2291
|
case "error-text":
|
|
2284
2292
|
contentValue = output.value;
|
|
2285
2293
|
break;
|
|
2294
|
+
case "execution-denied":
|
|
2295
|
+
contentValue = (_j = output.reason) != null ? _j : "Tool execution denied.";
|
|
2296
|
+
break;
|
|
2286
2297
|
case "content":
|
|
2287
2298
|
case "json":
|
|
2288
2299
|
case "error-json":
|
|
@@ -2519,6 +2530,7 @@ var imageGenerationArgsSchema = z18.object({
|
|
|
2519
2530
|
moderation: z18.enum(["auto"]).optional(),
|
|
2520
2531
|
outputCompression: z18.number().int().min(0).max(100).optional(),
|
|
2521
2532
|
outputFormat: z18.enum(["png", "jpeg", "webp"]).optional(),
|
|
2533
|
+
partialImages: z18.number().int().min(0).max(3).optional(),
|
|
2522
2534
|
quality: z18.enum(["auto", "low", "medium", "high"]).optional(),
|
|
2523
2535
|
size: z18.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
2524
2536
|
}).strict();
|
|
@@ -2531,6 +2543,9 @@ var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchem
|
|
|
2531
2543
|
inputSchema: z18.object({}),
|
|
2532
2544
|
outputSchema: imageGenerationOutputSchema
|
|
2533
2545
|
});
|
|
2546
|
+
var imageGeneration = (args = {}) => {
|
|
2547
|
+
return imageGenerationToolFactory(args);
|
|
2548
|
+
};
|
|
2534
2549
|
|
|
2535
2550
|
// src/responses/openai-responses-prepare-tools.ts
|
|
2536
2551
|
function prepareResponsesTools({
|
|
@@ -2615,11 +2630,12 @@ function prepareResponsesTools({
|
|
|
2615
2630
|
image_url: args.inputImageMask.imageUrl
|
|
2616
2631
|
} : void 0,
|
|
2617
2632
|
model: args.model,
|
|
2618
|
-
size: args.size,
|
|
2619
|
-
quality: args.quality,
|
|
2620
2633
|
moderation: args.moderation,
|
|
2634
|
+
partial_images: args.partialImages,
|
|
2635
|
+
quality: args.quality,
|
|
2636
|
+
output_compression: args.outputCompression,
|
|
2621
2637
|
output_format: args.outputFormat,
|
|
2622
|
-
|
|
2638
|
+
size: args.size
|
|
2623
2639
|
});
|
|
2624
2640
|
break;
|
|
2625
2641
|
}
|
|
@@ -3355,7 +3371,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3355
3371
|
controller.enqueue({
|
|
3356
3372
|
type: "tool-input-start",
|
|
3357
3373
|
id: value.item.id,
|
|
3358
|
-
toolName: webSearchToolName != null ? webSearchToolName : "web_search"
|
|
3374
|
+
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3375
|
+
providerExecuted: true
|
|
3359
3376
|
});
|
|
3360
3377
|
} else if (value.item.type === "computer_call") {
|
|
3361
3378
|
ongoingToolCalls[value.output_index] = {
|
|
@@ -3365,7 +3382,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3365
3382
|
controller.enqueue({
|
|
3366
3383
|
type: "tool-input-start",
|
|
3367
3384
|
id: value.item.id,
|
|
3368
|
-
toolName: "computer_use"
|
|
3385
|
+
toolName: "computer_use",
|
|
3386
|
+
providerExecuted: true
|
|
3369
3387
|
});
|
|
3370
3388
|
} else if (value.item.type === "code_interpreter_call") {
|
|
3371
3389
|
ongoingToolCalls[value.output_index] = {
|
|
@@ -3378,7 +3396,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3378
3396
|
controller.enqueue({
|
|
3379
3397
|
type: "tool-input-start",
|
|
3380
3398
|
id: value.item.id,
|
|
3381
|
-
toolName: "code_interpreter"
|
|
3399
|
+
toolName: "code_interpreter",
|
|
3400
|
+
providerExecuted: true
|
|
3382
3401
|
});
|
|
3383
3402
|
controller.enqueue({
|
|
3384
3403
|
type: "tool-input-delta",
|
|
@@ -3578,6 +3597,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3578
3597
|
delta: value.delta
|
|
3579
3598
|
});
|
|
3580
3599
|
}
|
|
3600
|
+
} else if (isResponseImageGenerationCallPartialImageChunk(value)) {
|
|
3601
|
+
controller.enqueue({
|
|
3602
|
+
type: "tool-result",
|
|
3603
|
+
toolCallId: value.item_id,
|
|
3604
|
+
toolName: "image_generation",
|
|
3605
|
+
result: {
|
|
3606
|
+
result: value.partial_image_b64
|
|
3607
|
+
},
|
|
3608
|
+
providerExecuted: true,
|
|
3609
|
+
preliminary: true
|
|
3610
|
+
});
|
|
3581
3611
|
} else if (isResponseCodeInterpreterCallCodeDeltaChunk(value)) {
|
|
3582
3612
|
const toolCall = ongoingToolCalls[value.output_index];
|
|
3583
3613
|
if (toolCall != null) {
|
|
@@ -3850,6 +3880,12 @@ var responseFunctionCallArgumentsDeltaSchema = z19.object({
|
|
|
3850
3880
|
output_index: z19.number(),
|
|
3851
3881
|
delta: z19.string()
|
|
3852
3882
|
});
|
|
3883
|
+
var responseImageGenerationCallPartialImageSchema = z19.object({
|
|
3884
|
+
type: z19.literal("response.image_generation_call.partial_image"),
|
|
3885
|
+
item_id: z19.string(),
|
|
3886
|
+
output_index: z19.number(),
|
|
3887
|
+
partial_image_b64: z19.string()
|
|
3888
|
+
});
|
|
3853
3889
|
var responseCodeInterpreterCallCodeDeltaSchema = z19.object({
|
|
3854
3890
|
type: z19.literal("response.code_interpreter_call_code.delta"),
|
|
3855
3891
|
item_id: z19.string(),
|
|
@@ -3899,6 +3935,7 @@ var openaiResponsesChunkSchema = z19.union([
|
|
|
3899
3935
|
responseOutputItemAddedSchema,
|
|
3900
3936
|
responseOutputItemDoneSchema,
|
|
3901
3937
|
responseFunctionCallArgumentsDeltaSchema,
|
|
3938
|
+
responseImageGenerationCallPartialImageSchema,
|
|
3902
3939
|
responseCodeInterpreterCallCodeDeltaSchema,
|
|
3903
3940
|
responseCodeInterpreterCallCodeDoneSchema,
|
|
3904
3941
|
responseAnnotationAddedSchema,
|
|
@@ -3926,6 +3963,9 @@ function isResponseCreatedChunk(chunk) {
|
|
|
3926
3963
|
function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
|
|
3927
3964
|
return chunk.type === "response.function_call_arguments.delta";
|
|
3928
3965
|
}
|
|
3966
|
+
function isResponseImageGenerationCallPartialImageChunk(chunk) {
|
|
3967
|
+
return chunk.type === "response.image_generation_call.partial_image";
|
|
3968
|
+
}
|
|
3929
3969
|
function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
|
|
3930
3970
|
return chunk.type === "response.code_interpreter_call_code.delta";
|
|
3931
3971
|
}
|
|
@@ -4042,6 +4082,9 @@ export {
|
|
|
4042
4082
|
fileSearchArgsSchema,
|
|
4043
4083
|
fileSearchOutputSchema,
|
|
4044
4084
|
hasDefaultResponseFormat,
|
|
4085
|
+
imageGeneration,
|
|
4086
|
+
imageGenerationArgsSchema,
|
|
4087
|
+
imageGenerationOutputSchema,
|
|
4045
4088
|
modelMaxImagesPerCall,
|
|
4046
4089
|
openAITranscriptionProviderOptions,
|
|
4047
4090
|
openaiChatLanguageModelOptions,
|