@ai-sdk/openai 3.0.63 → 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 +6 -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 +1 -1
- 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/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1052,6 +1052,7 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
|
|
|
1052
1052
|
safetyIdentifier?: string | null | undefined;
|
|
1053
1053
|
serviceTier?: "default" | "auto" | "flex" | "priority" | null | undefined;
|
|
1054
1054
|
store?: boolean | null | undefined;
|
|
1055
|
+
passThroughUnsupportedFiles?: boolean | undefined;
|
|
1055
1056
|
strictJsonSchema?: boolean | null | undefined;
|
|
1056
1057
|
textVerbosity?: "low" | "medium" | "high" | null | undefined;
|
|
1057
1058
|
truncation?: "auto" | "disabled" | null | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -1052,6 +1052,7 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
|
|
|
1052
1052
|
safetyIdentifier?: string | null | undefined;
|
|
1053
1053
|
serviceTier?: "default" | "auto" | "flex" | "priority" | null | undefined;
|
|
1054
1054
|
store?: boolean | null | undefined;
|
|
1055
|
+
passThroughUnsupportedFiles?: boolean | undefined;
|
|
1055
1056
|
strictJsonSchema?: boolean | null | undefined;
|
|
1056
1057
|
textVerbosity?: "low" | "medium" | "high" | null | undefined;
|
|
1057
1058
|
truncation?: "auto" | "disabled" | null | undefined;
|
package/dist/index.js
CHANGED
|
@@ -2741,6 +2741,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2741
2741
|
systemMessageMode,
|
|
2742
2742
|
providerOptionsName,
|
|
2743
2743
|
fileIdPrefixes,
|
|
2744
|
+
passThroughUnsupportedFiles = false,
|
|
2744
2745
|
store,
|
|
2745
2746
|
hasConversation = false,
|
|
2746
2747
|
hasLocalShellTool = false,
|
|
@@ -2790,8 +2791,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
2790
2791
|
return { type: "input_text", text: part.text };
|
|
2791
2792
|
}
|
|
2792
2793
|
case "file": {
|
|
2793
|
-
|
|
2794
|
-
|
|
2794
|
+
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
2795
|
+
if (mediaType.startsWith("image/")) {
|
|
2795
2796
|
return {
|
|
2796
2797
|
type: "input_image",
|
|
2797
2798
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
@@ -2799,25 +2800,25 @@ async function convertToOpenAIResponsesInput({
|
|
|
2799
2800
|
},
|
|
2800
2801
|
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
2801
2802
|
};
|
|
2802
|
-
}
|
|
2803
|
-
|
|
2804
|
-
return {
|
|
2805
|
-
type: "input_file",
|
|
2806
|
-
file_url: part.data.toString()
|
|
2807
|
-
};
|
|
2808
|
-
}
|
|
2803
|
+
}
|
|
2804
|
+
if (part.data instanceof URL) {
|
|
2809
2805
|
return {
|
|
2810
2806
|
type: "input_file",
|
|
2811
|
-
|
|
2812
|
-
filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
|
|
2813
|
-
file_data: `data:application/pdf;base64,${(0, import_provider_utils26.convertToBase64)(part.data)}`
|
|
2814
|
-
}
|
|
2807
|
+
file_url: part.data.toString()
|
|
2815
2808
|
};
|
|
2816
|
-
}
|
|
2809
|
+
}
|
|
2810
|
+
if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
|
|
2817
2811
|
throw new import_provider6.UnsupportedFunctionalityError({
|
|
2818
|
-
functionality: `file part media type ${
|
|
2812
|
+
functionality: `file part media type ${mediaType}`
|
|
2819
2813
|
});
|
|
2820
2814
|
}
|
|
2815
|
+
return {
|
|
2816
|
+
type: "input_file",
|
|
2817
|
+
...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2818
|
+
filename: (_c2 = part.filename) != null ? _c2 : mediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
|
|
2819
|
+
file_data: `data:${mediaType};base64,${(0, import_provider_utils26.convertToBase64)(part.data)}`
|
|
2820
|
+
}
|
|
2821
|
+
};
|
|
2821
2822
|
}
|
|
2822
2823
|
}
|
|
2823
2824
|
})
|
|
@@ -4384,6 +4385,14 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils28.lazy
|
|
|
4384
4385
|
* Whether to store the generation. Defaults to `true`.
|
|
4385
4386
|
*/
|
|
4386
4387
|
store: import_v423.z.boolean().nullish(),
|
|
4388
|
+
/**
|
|
4389
|
+
* Whether to pass through non-image file types as generic input files.
|
|
4390
|
+
*
|
|
4391
|
+
* By default, inline file inputs are restricted to images and PDFs.
|
|
4392
|
+
* Enable this when the target OpenAI Responses model supports additional
|
|
4393
|
+
* file media types, such as text/csv.
|
|
4394
|
+
*/
|
|
4395
|
+
passThroughUnsupportedFiles: import_v423.z.boolean().optional(),
|
|
4387
4396
|
/**
|
|
4388
4397
|
* Whether to use strict JSON schema validation.
|
|
4389
4398
|
* Defaults to `true`.
|
|
@@ -4778,7 +4787,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4778
4787
|
toolChoice,
|
|
4779
4788
|
responseFormat
|
|
4780
4789
|
}) {
|
|
4781
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
4790
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4782
4791
|
const warnings = [];
|
|
4783
4792
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
4784
4793
|
if (topK != null) {
|
|
@@ -4851,7 +4860,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4851
4860
|
systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
|
|
4852
4861
|
providerOptionsName,
|
|
4853
4862
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
4854
|
-
|
|
4863
|
+
passThroughUnsupportedFiles: (_d = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _d : false,
|
|
4864
|
+
store: (_e = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _e : true,
|
|
4855
4865
|
hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
|
|
4856
4866
|
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
4857
4867
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
@@ -4859,7 +4869,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4859
4869
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
4860
4870
|
});
|
|
4861
4871
|
warnings.push(...inputWarnings);
|
|
4862
|
-
const strictJsonSchema = (
|
|
4872
|
+
const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
|
|
4863
4873
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
4864
4874
|
function addInclude(key) {
|
|
4865
4875
|
if (include == null) {
|
|
@@ -4875,9 +4885,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4875
4885
|
if (topLogprobs) {
|
|
4876
4886
|
addInclude("message.output_text.logprobs");
|
|
4877
4887
|
}
|
|
4878
|
-
const webSearchToolName = (
|
|
4888
|
+
const webSearchToolName = (_g = tools == null ? void 0 : tools.find(
|
|
4879
4889
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
4880
|
-
)) == null ? void 0 :
|
|
4890
|
+
)) == null ? void 0 : _g.name;
|
|
4881
4891
|
if (webSearchToolName) {
|
|
4882
4892
|
addInclude("web_search_call.action.sources");
|
|
4883
4893
|
}
|
|
@@ -4900,7 +4910,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4900
4910
|
format: responseFormat.schema != null ? {
|
|
4901
4911
|
type: "json_schema",
|
|
4902
4912
|
strict: strictJsonSchema,
|
|
4903
|
-
name: (
|
|
4913
|
+
name: (_h = responseFormat.name) != null ? _h : "response",
|
|
4904
4914
|
description: responseFormat.description,
|
|
4905
4915
|
schema: responseFormat.schema
|
|
4906
4916
|
} : { type: "json_object" }
|
|
@@ -4989,9 +4999,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4989
4999
|
});
|
|
4990
5000
|
delete baseArgs.service_tier;
|
|
4991
5001
|
}
|
|
4992
|
-
const shellToolEnvType = (
|
|
5002
|
+
const shellToolEnvType = (_k = (_j = (_i = tools == null ? void 0 : tools.find(
|
|
4993
5003
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
4994
|
-
)) == null ? void 0 :
|
|
5004
|
+
)) == null ? void 0 : _i.args) == null ? void 0 : _j.environment) == null ? void 0 : _k.type;
|
|
4995
5005
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
4996
5006
|
return {
|
|
4997
5007
|
webSearchToolName,
|
|
@@ -6790,7 +6800,7 @@ var OpenAITranscriptionModel = class {
|
|
|
6790
6800
|
};
|
|
6791
6801
|
|
|
6792
6802
|
// src/version.ts
|
|
6793
|
-
var VERSION = true ? "3.0.
|
|
6803
|
+
var VERSION = true ? "3.0.64" : "0.0.0-test";
|
|
6794
6804
|
|
|
6795
6805
|
// src/openai-provider.ts
|
|
6796
6806
|
function createOpenAI(options = {}) {
|