@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/index.mjs
CHANGED
|
@@ -2837,6 +2837,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2837
2837
|
systemMessageMode,
|
|
2838
2838
|
providerOptionsName,
|
|
2839
2839
|
fileIdPrefixes,
|
|
2840
|
+
passThroughUnsupportedFiles = false,
|
|
2840
2841
|
store,
|
|
2841
2842
|
hasConversation = false,
|
|
2842
2843
|
hasLocalShellTool = false,
|
|
@@ -2886,8 +2887,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
2886
2887
|
return { type: "input_text", text: part.text };
|
|
2887
2888
|
}
|
|
2888
2889
|
case "file": {
|
|
2889
|
-
|
|
2890
|
-
|
|
2890
|
+
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
2891
|
+
if (mediaType.startsWith("image/")) {
|
|
2891
2892
|
return {
|
|
2892
2893
|
type: "input_image",
|
|
2893
2894
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
@@ -2895,25 +2896,25 @@ async function convertToOpenAIResponsesInput({
|
|
|
2895
2896
|
},
|
|
2896
2897
|
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
2897
2898
|
};
|
|
2898
|
-
}
|
|
2899
|
-
|
|
2900
|
-
return {
|
|
2901
|
-
type: "input_file",
|
|
2902
|
-
file_url: part.data.toString()
|
|
2903
|
-
};
|
|
2904
|
-
}
|
|
2899
|
+
}
|
|
2900
|
+
if (part.data instanceof URL) {
|
|
2905
2901
|
return {
|
|
2906
2902
|
type: "input_file",
|
|
2907
|
-
|
|
2908
|
-
filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
|
|
2909
|
-
file_data: `data:application/pdf;base64,${convertToBase642(part.data)}`
|
|
2910
|
-
}
|
|
2903
|
+
file_url: part.data.toString()
|
|
2911
2904
|
};
|
|
2912
|
-
}
|
|
2905
|
+
}
|
|
2906
|
+
if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
|
|
2913
2907
|
throw new UnsupportedFunctionalityError4({
|
|
2914
|
-
functionality: `file part media type ${
|
|
2908
|
+
functionality: `file part media type ${mediaType}`
|
|
2915
2909
|
});
|
|
2916
2910
|
}
|
|
2911
|
+
return {
|
|
2912
|
+
type: "input_file",
|
|
2913
|
+
...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2914
|
+
filename: (_c2 = part.filename) != null ? _c2 : mediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
|
|
2915
|
+
file_data: `data:${mediaType};base64,${convertToBase642(part.data)}`
|
|
2916
|
+
}
|
|
2917
|
+
};
|
|
2917
2918
|
}
|
|
2918
2919
|
}
|
|
2919
2920
|
})
|
|
@@ -4486,6 +4487,14 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema21(
|
|
|
4486
4487
|
* Whether to store the generation. Defaults to `true`.
|
|
4487
4488
|
*/
|
|
4488
4489
|
store: z23.boolean().nullish(),
|
|
4490
|
+
/**
|
|
4491
|
+
* Whether to pass through non-image file types as generic input files.
|
|
4492
|
+
*
|
|
4493
|
+
* By default, inline file inputs are restricted to images and PDFs.
|
|
4494
|
+
* Enable this when the target OpenAI Responses model supports additional
|
|
4495
|
+
* file media types, such as text/csv.
|
|
4496
|
+
*/
|
|
4497
|
+
passThroughUnsupportedFiles: z23.boolean().optional(),
|
|
4489
4498
|
/**
|
|
4490
4499
|
* Whether to use strict JSON schema validation.
|
|
4491
4500
|
* Defaults to `true`.
|
|
@@ -4882,7 +4891,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4882
4891
|
toolChoice,
|
|
4883
4892
|
responseFormat
|
|
4884
4893
|
}) {
|
|
4885
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
4894
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4886
4895
|
const warnings = [];
|
|
4887
4896
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
4888
4897
|
if (topK != null) {
|
|
@@ -4955,7 +4964,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4955
4964
|
systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
|
|
4956
4965
|
providerOptionsName,
|
|
4957
4966
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
4958
|
-
|
|
4967
|
+
passThroughUnsupportedFiles: (_d = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _d : false,
|
|
4968
|
+
store: (_e = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _e : true,
|
|
4959
4969
|
hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
|
|
4960
4970
|
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
4961
4971
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
@@ -4963,7 +4973,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4963
4973
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
4964
4974
|
});
|
|
4965
4975
|
warnings.push(...inputWarnings);
|
|
4966
|
-
const strictJsonSchema = (
|
|
4976
|
+
const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
|
|
4967
4977
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
4968
4978
|
function addInclude(key) {
|
|
4969
4979
|
if (include == null) {
|
|
@@ -4979,9 +4989,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4979
4989
|
if (topLogprobs) {
|
|
4980
4990
|
addInclude("message.output_text.logprobs");
|
|
4981
4991
|
}
|
|
4982
|
-
const webSearchToolName = (
|
|
4992
|
+
const webSearchToolName = (_g = tools == null ? void 0 : tools.find(
|
|
4983
4993
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
4984
|
-
)) == null ? void 0 :
|
|
4994
|
+
)) == null ? void 0 : _g.name;
|
|
4985
4995
|
if (webSearchToolName) {
|
|
4986
4996
|
addInclude("web_search_call.action.sources");
|
|
4987
4997
|
}
|
|
@@ -5004,7 +5014,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5004
5014
|
format: responseFormat.schema != null ? {
|
|
5005
5015
|
type: "json_schema",
|
|
5006
5016
|
strict: strictJsonSchema,
|
|
5007
|
-
name: (
|
|
5017
|
+
name: (_h = responseFormat.name) != null ? _h : "response",
|
|
5008
5018
|
description: responseFormat.description,
|
|
5009
5019
|
schema: responseFormat.schema
|
|
5010
5020
|
} : { type: "json_object" }
|
|
@@ -5093,9 +5103,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5093
5103
|
});
|
|
5094
5104
|
delete baseArgs.service_tier;
|
|
5095
5105
|
}
|
|
5096
|
-
const shellToolEnvType = (
|
|
5106
|
+
const shellToolEnvType = (_k = (_j = (_i = tools == null ? void 0 : tools.find(
|
|
5097
5107
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
5098
|
-
)) == null ? void 0 :
|
|
5108
|
+
)) == null ? void 0 : _i.args) == null ? void 0 : _j.environment) == null ? void 0 : _k.type;
|
|
5099
5109
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
5100
5110
|
return {
|
|
5101
5111
|
webSearchToolName,
|
|
@@ -6912,7 +6922,7 @@ var OpenAITranscriptionModel = class {
|
|
|
6912
6922
|
};
|
|
6913
6923
|
|
|
6914
6924
|
// src/version.ts
|
|
6915
|
-
var VERSION = true ? "3.0.
|
|
6925
|
+
var VERSION = true ? "3.0.64" : "0.0.0-test";
|
|
6916
6926
|
|
|
6917
6927
|
// src/openai-provider.ts
|
|
6918
6928
|
function createOpenAI(options = {}) {
|