@ai-sdk/openai 2.1.0-beta.10 → 2.1.0-beta.12
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 +23 -0
- package/dist/index.d.mts +14 -8
- package/dist/index.d.ts +14 -8
- package/dist/index.js +49 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -14
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +13 -8
- package/dist/internal/index.d.ts +13 -8
- package/dist/internal/index.js +38 -8
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +38 -8
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -49,6 +49,7 @@ function convertToOpenAIChatMessages({
|
|
|
49
49
|
prompt,
|
|
50
50
|
systemMessageMode = "system"
|
|
51
51
|
}) {
|
|
52
|
+
var _a;
|
|
52
53
|
const messages = [];
|
|
53
54
|
const warnings = [];
|
|
54
55
|
for (const { role, content } of prompt) {
|
|
@@ -87,7 +88,7 @@ function convertToOpenAIChatMessages({
|
|
|
87
88
|
messages.push({
|
|
88
89
|
role: "user",
|
|
89
90
|
content: content.map((part, index) => {
|
|
90
|
-
var
|
|
91
|
+
var _a2, _b, _c;
|
|
91
92
|
switch (part.type) {
|
|
92
93
|
case "text": {
|
|
93
94
|
return { type: "text", text: part.text };
|
|
@@ -100,7 +101,7 @@ function convertToOpenAIChatMessages({
|
|
|
100
101
|
image_url: {
|
|
101
102
|
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
|
|
102
103
|
// OpenAI specific extension: image detail
|
|
103
|
-
detail: (_b = (
|
|
104
|
+
detail: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.imageDetail
|
|
104
105
|
}
|
|
105
106
|
};
|
|
106
107
|
} else if (part.mediaType.startsWith("audio/")) {
|
|
@@ -197,6 +198,9 @@ function convertToOpenAIChatMessages({
|
|
|
197
198
|
case "error-text":
|
|
198
199
|
contentValue = output.value;
|
|
199
200
|
break;
|
|
201
|
+
case "execution-denied":
|
|
202
|
+
contentValue = (_a = output.reason) != null ? _a : "Tool execution denied.";
|
|
203
|
+
break;
|
|
200
204
|
case "content":
|
|
201
205
|
case "json":
|
|
202
206
|
case "error-json":
|
|
@@ -1778,6 +1782,7 @@ var imageGenerationArgsSchema = z11.object({
|
|
|
1778
1782
|
moderation: z11.enum(["auto"]).optional(),
|
|
1779
1783
|
outputCompression: z11.number().int().min(0).max(100).optional(),
|
|
1780
1784
|
outputFormat: z11.enum(["png", "jpeg", "webp"]).optional(),
|
|
1785
|
+
partialImages: z11.number().int().min(0).max(3).optional(),
|
|
1781
1786
|
quality: z11.enum(["auto", "low", "medium", "high"]).optional(),
|
|
1782
1787
|
size: z11.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
1783
1788
|
}).strict();
|
|
@@ -1949,11 +1954,16 @@ var openaiTools = {
|
|
|
1949
1954
|
*
|
|
1950
1955
|
* Must have name `image_generation`.
|
|
1951
1956
|
*
|
|
1952
|
-
* @param
|
|
1953
|
-
* @param
|
|
1954
|
-
* @param
|
|
1955
|
-
* @param
|
|
1956
|
-
* @param
|
|
1957
|
+
* @param background - Background type for the generated image. One of 'auto', 'opaque', or 'transparent'.
|
|
1958
|
+
* @param inputFidelity - Input fidelity for the generated image. One of 'low' or 'high'.
|
|
1959
|
+
* @param inputImageMask - Optional mask for inpainting. Contains fileId and/or imageUrl.
|
|
1960
|
+
* @param model - The image generation model to use. Default: gpt-image-1.
|
|
1961
|
+
* @param moderation - Moderation level for the generated image. Default: 'auto'.
|
|
1962
|
+
* @param outputCompression - Compression level for the output image (0-100).
|
|
1963
|
+
* @param outputFormat - The output format of the generated image. One of 'png', 'jpeg', or 'webp'.
|
|
1964
|
+
* @param partialImages - Number of partial images to generate in streaming mode (0-3).
|
|
1965
|
+
* @param quality - The quality of the generated image. One of 'auto', 'low', 'medium', or 'high'.
|
|
1966
|
+
* @param size - The size of the generated image. One of 'auto', '1024x1024', '1024x1536', or '1536x1024'.
|
|
1957
1967
|
*/
|
|
1958
1968
|
imageGeneration,
|
|
1959
1969
|
/**
|
|
@@ -2021,7 +2031,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2021
2031
|
store,
|
|
2022
2032
|
hasLocalShellTool = false
|
|
2023
2033
|
}) {
|
|
2024
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2034
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2025
2035
|
const input = [];
|
|
2026
2036
|
const warnings = [];
|
|
2027
2037
|
for (const { role, content } of prompt) {
|
|
@@ -2224,6 +2234,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2224
2234
|
case "error-text":
|
|
2225
2235
|
contentValue = output.value;
|
|
2226
2236
|
break;
|
|
2237
|
+
case "execution-denied":
|
|
2238
|
+
contentValue = (_j = output.reason) != null ? _j : "Tool execution denied.";
|
|
2239
|
+
break;
|
|
2227
2240
|
case "content":
|
|
2228
2241
|
case "json":
|
|
2229
2242
|
case "error-json":
|
|
@@ -2355,11 +2368,12 @@ function prepareResponsesTools({
|
|
|
2355
2368
|
image_url: args.inputImageMask.imageUrl
|
|
2356
2369
|
} : void 0,
|
|
2357
2370
|
model: args.model,
|
|
2358
|
-
size: args.size,
|
|
2359
|
-
quality: args.quality,
|
|
2360
2371
|
moderation: args.moderation,
|
|
2372
|
+
partial_images: args.partialImages,
|
|
2373
|
+
quality: args.quality,
|
|
2374
|
+
output_compression: args.outputCompression,
|
|
2361
2375
|
output_format: args.outputFormat,
|
|
2362
|
-
|
|
2376
|
+
size: args.size
|
|
2363
2377
|
});
|
|
2364
2378
|
break;
|
|
2365
2379
|
}
|
|
@@ -3318,6 +3332,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3318
3332
|
delta: value.delta
|
|
3319
3333
|
});
|
|
3320
3334
|
}
|
|
3335
|
+
} else if (isResponseImageGenerationCallPartialImageChunk(value)) {
|
|
3336
|
+
controller.enqueue({
|
|
3337
|
+
type: "tool-result",
|
|
3338
|
+
toolCallId: value.item_id,
|
|
3339
|
+
toolName: "image_generation",
|
|
3340
|
+
result: {
|
|
3341
|
+
result: value.partial_image_b64
|
|
3342
|
+
},
|
|
3343
|
+
providerExecuted: true,
|
|
3344
|
+
preliminary: true
|
|
3345
|
+
});
|
|
3321
3346
|
} else if (isResponseCodeInterpreterCallCodeDeltaChunk(value)) {
|
|
3322
3347
|
const toolCall = ongoingToolCalls[value.output_index];
|
|
3323
3348
|
if (toolCall != null) {
|
|
@@ -3590,6 +3615,12 @@ var responseFunctionCallArgumentsDeltaSchema = z16.object({
|
|
|
3590
3615
|
output_index: z16.number(),
|
|
3591
3616
|
delta: z16.string()
|
|
3592
3617
|
});
|
|
3618
|
+
var responseImageGenerationCallPartialImageSchema = z16.object({
|
|
3619
|
+
type: z16.literal("response.image_generation_call.partial_image"),
|
|
3620
|
+
item_id: z16.string(),
|
|
3621
|
+
output_index: z16.number(),
|
|
3622
|
+
partial_image_b64: z16.string()
|
|
3623
|
+
});
|
|
3593
3624
|
var responseCodeInterpreterCallCodeDeltaSchema = z16.object({
|
|
3594
3625
|
type: z16.literal("response.code_interpreter_call_code.delta"),
|
|
3595
3626
|
item_id: z16.string(),
|
|
@@ -3639,6 +3670,7 @@ var openaiResponsesChunkSchema = z16.union([
|
|
|
3639
3670
|
responseOutputItemAddedSchema,
|
|
3640
3671
|
responseOutputItemDoneSchema,
|
|
3641
3672
|
responseFunctionCallArgumentsDeltaSchema,
|
|
3673
|
+
responseImageGenerationCallPartialImageSchema,
|
|
3642
3674
|
responseCodeInterpreterCallCodeDeltaSchema,
|
|
3643
3675
|
responseCodeInterpreterCallCodeDoneSchema,
|
|
3644
3676
|
responseAnnotationAddedSchema,
|
|
@@ -3666,6 +3698,9 @@ function isResponseCreatedChunk(chunk) {
|
|
|
3666
3698
|
function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
|
|
3667
3699
|
return chunk.type === "response.function_call_arguments.delta";
|
|
3668
3700
|
}
|
|
3701
|
+
function isResponseImageGenerationCallPartialImageChunk(chunk) {
|
|
3702
|
+
return chunk.type === "response.image_generation_call.partial_image";
|
|
3703
|
+
}
|
|
3669
3704
|
function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
|
|
3670
3705
|
return chunk.type === "response.code_interpreter_call_code.delta";
|
|
3671
3706
|
}
|
|
@@ -3782,7 +3817,7 @@ var OpenAISpeechModel = class {
|
|
|
3782
3817
|
constructor(modelId, config) {
|
|
3783
3818
|
this.modelId = modelId;
|
|
3784
3819
|
this.config = config;
|
|
3785
|
-
this.specificationVersion = "
|
|
3820
|
+
this.specificationVersion = "v3";
|
|
3786
3821
|
}
|
|
3787
3822
|
get provider() {
|
|
3788
3823
|
return this.config.provider;
|
|
@@ -3980,7 +4015,7 @@ var OpenAITranscriptionModel = class {
|
|
|
3980
4015
|
constructor(modelId, config) {
|
|
3981
4016
|
this.modelId = modelId;
|
|
3982
4017
|
this.config = config;
|
|
3983
|
-
this.specificationVersion = "
|
|
4018
|
+
this.specificationVersion = "v3";
|
|
3984
4019
|
}
|
|
3985
4020
|
get provider() {
|
|
3986
4021
|
return this.config.provider;
|
|
@@ -4110,7 +4145,7 @@ var openaiTranscriptionResponseSchema = z19.object({
|
|
|
4110
4145
|
});
|
|
4111
4146
|
|
|
4112
4147
|
// src/version.ts
|
|
4113
|
-
var VERSION = true ? "2.1.0-beta.
|
|
4148
|
+
var VERSION = true ? "2.1.0-beta.12" : "0.0.0-test";
|
|
4114
4149
|
|
|
4115
4150
|
// src/openai-provider.ts
|
|
4116
4151
|
function createOpenAI(options = {}) {
|