@ai-sdk/openai 3.0.62 → 3.0.64
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 +13 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +34 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -24
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +33 -23
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +33 -23
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +4 -0
- package/package.json +2 -2
- package/src/responses/convert-to-openai-responses-input.ts +31 -21
- package/src/responses/openai-responses-language-model.ts +2 -0
- package/src/responses/openai-responses-options.ts +9 -0
package/dist/internal/index.js
CHANGED
|
@@ -2686,6 +2686,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2686
2686
|
systemMessageMode,
|
|
2687
2687
|
providerOptionsName,
|
|
2688
2688
|
fileIdPrefixes,
|
|
2689
|
+
passThroughUnsupportedFiles = false,
|
|
2689
2690
|
store,
|
|
2690
2691
|
hasConversation = false,
|
|
2691
2692
|
hasLocalShellTool = false,
|
|
@@ -2735,8 +2736,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
2735
2736
|
return { type: "input_text", text: part.text };
|
|
2736
2737
|
}
|
|
2737
2738
|
case "file": {
|
|
2738
|
-
|
|
2739
|
-
|
|
2739
|
+
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
2740
|
+
if (mediaType.startsWith("image/")) {
|
|
2740
2741
|
return {
|
|
2741
2742
|
type: "input_image",
|
|
2742
2743
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
@@ -2744,25 +2745,25 @@ async function convertToOpenAIResponsesInput({
|
|
|
2744
2745
|
},
|
|
2745
2746
|
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
2746
2747
|
};
|
|
2747
|
-
}
|
|
2748
|
-
|
|
2749
|
-
return {
|
|
2750
|
-
type: "input_file",
|
|
2751
|
-
file_url: part.data.toString()
|
|
2752
|
-
};
|
|
2753
|
-
}
|
|
2748
|
+
}
|
|
2749
|
+
if (part.data instanceof URL) {
|
|
2754
2750
|
return {
|
|
2755
2751
|
type: "input_file",
|
|
2756
|
-
|
|
2757
|
-
filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
|
|
2758
|
-
file_data: `data:application/pdf;base64,${(0, import_provider_utils24.convertToBase64)(part.data)}`
|
|
2759
|
-
}
|
|
2752
|
+
file_url: part.data.toString()
|
|
2760
2753
|
};
|
|
2761
|
-
}
|
|
2754
|
+
}
|
|
2755
|
+
if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
|
|
2762
2756
|
throw new import_provider6.UnsupportedFunctionalityError({
|
|
2763
|
-
functionality: `file part media type ${
|
|
2757
|
+
functionality: `file part media type ${mediaType}`
|
|
2764
2758
|
});
|
|
2765
2759
|
}
|
|
2760
|
+
return {
|
|
2761
|
+
type: "input_file",
|
|
2762
|
+
...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2763
|
+
filename: (_c2 = part.filename) != null ? _c2 : mediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
|
|
2764
|
+
file_data: `data:${mediaType};base64,${(0, import_provider_utils24.convertToBase64)(part.data)}`
|
|
2765
|
+
}
|
|
2766
|
+
};
|
|
2766
2767
|
}
|
|
2767
2768
|
}
|
|
2768
2769
|
})
|
|
@@ -4329,6 +4330,14 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils26.lazy
|
|
|
4329
4330
|
* Whether to store the generation. Defaults to `true`.
|
|
4330
4331
|
*/
|
|
4331
4332
|
store: import_v419.z.boolean().nullish(),
|
|
4333
|
+
/**
|
|
4334
|
+
* Whether to pass through non-image file types as generic input files.
|
|
4335
|
+
*
|
|
4336
|
+
* By default, inline file inputs are restricted to images and PDFs.
|
|
4337
|
+
* Enable this when the target OpenAI Responses model supports additional
|
|
4338
|
+
* file media types, such as text/csv.
|
|
4339
|
+
*/
|
|
4340
|
+
passThroughUnsupportedFiles: import_v419.z.boolean().optional(),
|
|
4332
4341
|
/**
|
|
4333
4342
|
* Whether to use strict JSON schema validation.
|
|
4334
4343
|
* Defaults to `true`.
|
|
@@ -5042,7 +5051,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5042
5051
|
toolChoice,
|
|
5043
5052
|
responseFormat
|
|
5044
5053
|
}) {
|
|
5045
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
5054
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
5046
5055
|
const warnings = [];
|
|
5047
5056
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
5048
5057
|
if (topK != null) {
|
|
@@ -5115,7 +5124,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5115
5124
|
systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
|
|
5116
5125
|
providerOptionsName,
|
|
5117
5126
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
5118
|
-
|
|
5127
|
+
passThroughUnsupportedFiles: (_d = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _d : false,
|
|
5128
|
+
store: (_e = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _e : true,
|
|
5119
5129
|
hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
|
|
5120
5130
|
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
5121
5131
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
@@ -5123,7 +5133,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5123
5133
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
5124
5134
|
});
|
|
5125
5135
|
warnings.push(...inputWarnings);
|
|
5126
|
-
const strictJsonSchema = (
|
|
5136
|
+
const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
|
|
5127
5137
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
5128
5138
|
function addInclude(key) {
|
|
5129
5139
|
if (include == null) {
|
|
@@ -5139,9 +5149,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5139
5149
|
if (topLogprobs) {
|
|
5140
5150
|
addInclude("message.output_text.logprobs");
|
|
5141
5151
|
}
|
|
5142
|
-
const webSearchToolName = (
|
|
5152
|
+
const webSearchToolName = (_g = tools == null ? void 0 : tools.find(
|
|
5143
5153
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
5144
|
-
)) == null ? void 0 :
|
|
5154
|
+
)) == null ? void 0 : _g.name;
|
|
5145
5155
|
if (webSearchToolName) {
|
|
5146
5156
|
addInclude("web_search_call.action.sources");
|
|
5147
5157
|
}
|
|
@@ -5164,7 +5174,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5164
5174
|
format: responseFormat.schema != null ? {
|
|
5165
5175
|
type: "json_schema",
|
|
5166
5176
|
strict: strictJsonSchema,
|
|
5167
|
-
name: (
|
|
5177
|
+
name: (_h = responseFormat.name) != null ? _h : "response",
|
|
5168
5178
|
description: responseFormat.description,
|
|
5169
5179
|
schema: responseFormat.schema
|
|
5170
5180
|
} : { type: "json_object" }
|
|
@@ -5253,9 +5263,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5253
5263
|
});
|
|
5254
5264
|
delete baseArgs.service_tier;
|
|
5255
5265
|
}
|
|
5256
|
-
const shellToolEnvType = (
|
|
5266
|
+
const shellToolEnvType = (_k = (_j = (_i = tools == null ? void 0 : tools.find(
|
|
5257
5267
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
5258
|
-
)) == null ? void 0 :
|
|
5268
|
+
)) == null ? void 0 : _i.args) == null ? void 0 : _j.environment) == null ? void 0 : _k.type;
|
|
5259
5269
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
5260
5270
|
return {
|
|
5261
5271
|
webSearchToolName,
|