@ai-sdk/openai 3.0.63 → 3.0.65
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 +12 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +40 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -25
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +39 -24
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +39 -24
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +4 -0
- package/package.json +1 -1
- package/src/responses/convert-to-openai-responses-input.ts +40 -22
- package/src/responses/openai-responses-language-model.ts +3 -0
- package/src/responses/openai-responses-options.ts +9 -0
package/dist/internal/index.mjs
CHANGED
|
@@ -2734,8 +2734,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2734
2734
|
systemMessageMode,
|
|
2735
2735
|
providerOptionsName,
|
|
2736
2736
|
fileIdPrefixes,
|
|
2737
|
+
passThroughUnsupportedFiles = false,
|
|
2737
2738
|
store,
|
|
2738
2739
|
hasConversation = false,
|
|
2740
|
+
hasPreviousResponseId = false,
|
|
2739
2741
|
hasLocalShellTool = false,
|
|
2740
2742
|
hasShellTool = false,
|
|
2741
2743
|
hasApplyPatchTool = false,
|
|
@@ -2783,8 +2785,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
2783
2785
|
return { type: "input_text", text: part.text };
|
|
2784
2786
|
}
|
|
2785
2787
|
case "file": {
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
+
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
2789
|
+
if (mediaType.startsWith("image/")) {
|
|
2788
2790
|
return {
|
|
2789
2791
|
type: "input_image",
|
|
2790
2792
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
@@ -2792,25 +2794,25 @@ async function convertToOpenAIResponsesInput({
|
|
|
2792
2794
|
},
|
|
2793
2795
|
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
2794
2796
|
};
|
|
2795
|
-
}
|
|
2796
|
-
|
|
2797
|
-
return {
|
|
2798
|
-
type: "input_file",
|
|
2799
|
-
file_url: part.data.toString()
|
|
2800
|
-
};
|
|
2801
|
-
}
|
|
2797
|
+
}
|
|
2798
|
+
if (part.data instanceof URL) {
|
|
2802
2799
|
return {
|
|
2803
2800
|
type: "input_file",
|
|
2804
|
-
|
|
2805
|
-
filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
|
|
2806
|
-
file_data: `data:application/pdf;base64,${convertToBase642(part.data)}`
|
|
2807
|
-
}
|
|
2801
|
+
file_url: part.data.toString()
|
|
2808
2802
|
};
|
|
2809
|
-
}
|
|
2803
|
+
}
|
|
2804
|
+
if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
|
|
2810
2805
|
throw new UnsupportedFunctionalityError4({
|
|
2811
|
-
functionality: `file part media type ${
|
|
2806
|
+
functionality: `file part media type ${mediaType}`
|
|
2812
2807
|
});
|
|
2813
2808
|
}
|
|
2809
|
+
return {
|
|
2810
|
+
type: "input_file",
|
|
2811
|
+
...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2812
|
+
filename: (_c2 = part.filename) != null ? _c2 : mediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
|
|
2813
|
+
file_data: `data:${mediaType};base64,${convertToBase642(part.data)}`
|
|
2814
|
+
}
|
|
2815
|
+
};
|
|
2814
2816
|
}
|
|
2815
2817
|
}
|
|
2816
2818
|
})
|
|
@@ -2878,6 +2880,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2878
2880
|
break;
|
|
2879
2881
|
}
|
|
2880
2882
|
if (store && id != null) {
|
|
2883
|
+
if (hasPreviousResponseId) {
|
|
2884
|
+
break;
|
|
2885
|
+
}
|
|
2881
2886
|
input.push({ type: "item_reference", id });
|
|
2882
2887
|
break;
|
|
2883
2888
|
}
|
|
@@ -3022,7 +3027,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3022
3027
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
3023
3028
|
});
|
|
3024
3029
|
const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
|
|
3025
|
-
if (hasConversation && reasoningId != null) {
|
|
3030
|
+
if ((hasConversation || hasPreviousResponseId) && reasoningId != null) {
|
|
3026
3031
|
break;
|
|
3027
3032
|
}
|
|
3028
3033
|
if (reasoningId != null) {
|
|
@@ -4383,6 +4388,14 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema17(
|
|
|
4383
4388
|
* Whether to store the generation. Defaults to `true`.
|
|
4384
4389
|
*/
|
|
4385
4390
|
store: z19.boolean().nullish(),
|
|
4391
|
+
/**
|
|
4392
|
+
* Whether to pass through non-image file types as generic input files.
|
|
4393
|
+
*
|
|
4394
|
+
* By default, inline file inputs are restricted to images and PDFs.
|
|
4395
|
+
* Enable this when the target OpenAI Responses model supports additional
|
|
4396
|
+
* file media types, such as text/csv.
|
|
4397
|
+
*/
|
|
4398
|
+
passThroughUnsupportedFiles: z19.boolean().optional(),
|
|
4386
4399
|
/**
|
|
4387
4400
|
* Whether to use strict JSON schema validation.
|
|
4388
4401
|
* Defaults to `true`.
|
|
@@ -5126,7 +5139,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5126
5139
|
toolChoice,
|
|
5127
5140
|
responseFormat
|
|
5128
5141
|
}) {
|
|
5129
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
5142
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
5130
5143
|
const warnings = [];
|
|
5131
5144
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
5132
5145
|
if (topK != null) {
|
|
@@ -5199,15 +5212,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5199
5212
|
systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
|
|
5200
5213
|
providerOptionsName,
|
|
5201
5214
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
5202
|
-
|
|
5215
|
+
passThroughUnsupportedFiles: (_d = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _d : false,
|
|
5216
|
+
store: (_e = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _e : true,
|
|
5203
5217
|
hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
|
|
5218
|
+
hasPreviousResponseId: (openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null,
|
|
5204
5219
|
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
5205
5220
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
5206
5221
|
hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
|
|
5207
5222
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
5208
5223
|
});
|
|
5209
5224
|
warnings.push(...inputWarnings);
|
|
5210
|
-
const strictJsonSchema = (
|
|
5225
|
+
const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
|
|
5211
5226
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
5212
5227
|
function addInclude(key) {
|
|
5213
5228
|
if (include == null) {
|
|
@@ -5223,9 +5238,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5223
5238
|
if (topLogprobs) {
|
|
5224
5239
|
addInclude("message.output_text.logprobs");
|
|
5225
5240
|
}
|
|
5226
|
-
const webSearchToolName = (
|
|
5241
|
+
const webSearchToolName = (_g = tools == null ? void 0 : tools.find(
|
|
5227
5242
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
5228
|
-
)) == null ? void 0 :
|
|
5243
|
+
)) == null ? void 0 : _g.name;
|
|
5229
5244
|
if (webSearchToolName) {
|
|
5230
5245
|
addInclude("web_search_call.action.sources");
|
|
5231
5246
|
}
|
|
@@ -5248,7 +5263,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5248
5263
|
format: responseFormat.schema != null ? {
|
|
5249
5264
|
type: "json_schema",
|
|
5250
5265
|
strict: strictJsonSchema,
|
|
5251
|
-
name: (
|
|
5266
|
+
name: (_h = responseFormat.name) != null ? _h : "response",
|
|
5252
5267
|
description: responseFormat.description,
|
|
5253
5268
|
schema: responseFormat.schema
|
|
5254
5269
|
} : { type: "json_object" }
|
|
@@ -5337,9 +5352,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5337
5352
|
});
|
|
5338
5353
|
delete baseArgs.service_tier;
|
|
5339
5354
|
}
|
|
5340
|
-
const shellToolEnvType = (
|
|
5355
|
+
const shellToolEnvType = (_k = (_j = (_i = tools == null ? void 0 : tools.find(
|
|
5341
5356
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
5342
|
-
)) == null ? void 0 :
|
|
5357
|
+
)) == null ? void 0 : _i.args) == null ? void 0 : _j.environment) == null ? void 0 : _k.type;
|
|
5343
5358
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
5344
5359
|
return {
|
|
5345
5360
|
webSearchToolName,
|