@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 3.0.65
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- eb52378: fix(openai): skip passing reasoning items when using previous response id
|
|
8
|
+
|
|
9
|
+
## 3.0.64
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- b7ed8bd: feat(openai): add opt-in pass-through for unsupported file media types
|
|
14
|
+
|
|
3
15
|
## 3.0.63
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
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,8 +2741,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2741
2741
|
systemMessageMode,
|
|
2742
2742
|
providerOptionsName,
|
|
2743
2743
|
fileIdPrefixes,
|
|
2744
|
+
passThroughUnsupportedFiles = false,
|
|
2744
2745
|
store,
|
|
2745
2746
|
hasConversation = false,
|
|
2747
|
+
hasPreviousResponseId = false,
|
|
2746
2748
|
hasLocalShellTool = false,
|
|
2747
2749
|
hasShellTool = false,
|
|
2748
2750
|
hasApplyPatchTool = false,
|
|
@@ -2790,8 +2792,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
2790
2792
|
return { type: "input_text", text: part.text };
|
|
2791
2793
|
}
|
|
2792
2794
|
case "file": {
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
+
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
2796
|
+
if (mediaType.startsWith("image/")) {
|
|
2795
2797
|
return {
|
|
2796
2798
|
type: "input_image",
|
|
2797
2799
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
@@ -2799,25 +2801,25 @@ async function convertToOpenAIResponsesInput({
|
|
|
2799
2801
|
},
|
|
2800
2802
|
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
|
|
2801
2803
|
};
|
|
2802
|
-
}
|
|
2803
|
-
|
|
2804
|
-
return {
|
|
2805
|
-
type: "input_file",
|
|
2806
|
-
file_url: part.data.toString()
|
|
2807
|
-
};
|
|
2808
|
-
}
|
|
2804
|
+
}
|
|
2805
|
+
if (part.data instanceof URL) {
|
|
2809
2806
|
return {
|
|
2810
2807
|
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
|
-
}
|
|
2808
|
+
file_url: part.data.toString()
|
|
2815
2809
|
};
|
|
2816
|
-
}
|
|
2810
|
+
}
|
|
2811
|
+
if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
|
|
2817
2812
|
throw new import_provider6.UnsupportedFunctionalityError({
|
|
2818
|
-
functionality: `file part media type ${
|
|
2813
|
+
functionality: `file part media type ${mediaType}`
|
|
2819
2814
|
});
|
|
2820
2815
|
}
|
|
2816
|
+
return {
|
|
2817
|
+
type: "input_file",
|
|
2818
|
+
...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2819
|
+
filename: (_c2 = part.filename) != null ? _c2 : mediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
|
|
2820
|
+
file_data: `data:${mediaType};base64,${(0, import_provider_utils26.convertToBase64)(part.data)}`
|
|
2821
|
+
}
|
|
2822
|
+
};
|
|
2821
2823
|
}
|
|
2822
2824
|
}
|
|
2823
2825
|
})
|
|
@@ -2885,6 +2887,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2885
2887
|
break;
|
|
2886
2888
|
}
|
|
2887
2889
|
if (store && id != null) {
|
|
2890
|
+
if (hasPreviousResponseId) {
|
|
2891
|
+
break;
|
|
2892
|
+
}
|
|
2888
2893
|
input.push({ type: "item_reference", id });
|
|
2889
2894
|
break;
|
|
2890
2895
|
}
|
|
@@ -3029,7 +3034,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3029
3034
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
3030
3035
|
});
|
|
3031
3036
|
const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
|
|
3032
|
-
if (hasConversation && reasoningId != null) {
|
|
3037
|
+
if ((hasConversation || hasPreviousResponseId) && reasoningId != null) {
|
|
3033
3038
|
break;
|
|
3034
3039
|
}
|
|
3035
3040
|
if (reasoningId != null) {
|
|
@@ -4384,6 +4389,14 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils28.lazy
|
|
|
4384
4389
|
* Whether to store the generation. Defaults to `true`.
|
|
4385
4390
|
*/
|
|
4386
4391
|
store: import_v423.z.boolean().nullish(),
|
|
4392
|
+
/**
|
|
4393
|
+
* Whether to pass through non-image file types as generic input files.
|
|
4394
|
+
*
|
|
4395
|
+
* By default, inline file inputs are restricted to images and PDFs.
|
|
4396
|
+
* Enable this when the target OpenAI Responses model supports additional
|
|
4397
|
+
* file media types, such as text/csv.
|
|
4398
|
+
*/
|
|
4399
|
+
passThroughUnsupportedFiles: import_v423.z.boolean().optional(),
|
|
4387
4400
|
/**
|
|
4388
4401
|
* Whether to use strict JSON schema validation.
|
|
4389
4402
|
* Defaults to `true`.
|
|
@@ -4778,7 +4791,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4778
4791
|
toolChoice,
|
|
4779
4792
|
responseFormat
|
|
4780
4793
|
}) {
|
|
4781
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
4794
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4782
4795
|
const warnings = [];
|
|
4783
4796
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
4784
4797
|
if (topK != null) {
|
|
@@ -4851,15 +4864,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4851
4864
|
systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
|
|
4852
4865
|
providerOptionsName,
|
|
4853
4866
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
4854
|
-
|
|
4867
|
+
passThroughUnsupportedFiles: (_d = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _d : false,
|
|
4868
|
+
store: (_e = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _e : true,
|
|
4855
4869
|
hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
|
|
4870
|
+
hasPreviousResponseId: (openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null,
|
|
4856
4871
|
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
4857
4872
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
4858
4873
|
hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
|
|
4859
4874
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
4860
4875
|
});
|
|
4861
4876
|
warnings.push(...inputWarnings);
|
|
4862
|
-
const strictJsonSchema = (
|
|
4877
|
+
const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
|
|
4863
4878
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
4864
4879
|
function addInclude(key) {
|
|
4865
4880
|
if (include == null) {
|
|
@@ -4875,9 +4890,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4875
4890
|
if (topLogprobs) {
|
|
4876
4891
|
addInclude("message.output_text.logprobs");
|
|
4877
4892
|
}
|
|
4878
|
-
const webSearchToolName = (
|
|
4893
|
+
const webSearchToolName = (_g = tools == null ? void 0 : tools.find(
|
|
4879
4894
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
4880
|
-
)) == null ? void 0 :
|
|
4895
|
+
)) == null ? void 0 : _g.name;
|
|
4881
4896
|
if (webSearchToolName) {
|
|
4882
4897
|
addInclude("web_search_call.action.sources");
|
|
4883
4898
|
}
|
|
@@ -4900,7 +4915,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4900
4915
|
format: responseFormat.schema != null ? {
|
|
4901
4916
|
type: "json_schema",
|
|
4902
4917
|
strict: strictJsonSchema,
|
|
4903
|
-
name: (
|
|
4918
|
+
name: (_h = responseFormat.name) != null ? _h : "response",
|
|
4904
4919
|
description: responseFormat.description,
|
|
4905
4920
|
schema: responseFormat.schema
|
|
4906
4921
|
} : { type: "json_object" }
|
|
@@ -4989,9 +5004,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4989
5004
|
});
|
|
4990
5005
|
delete baseArgs.service_tier;
|
|
4991
5006
|
}
|
|
4992
|
-
const shellToolEnvType = (
|
|
5007
|
+
const shellToolEnvType = (_k = (_j = (_i = tools == null ? void 0 : tools.find(
|
|
4993
5008
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
4994
|
-
)) == null ? void 0 :
|
|
5009
|
+
)) == null ? void 0 : _i.args) == null ? void 0 : _j.environment) == null ? void 0 : _k.type;
|
|
4995
5010
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
4996
5011
|
return {
|
|
4997
5012
|
webSearchToolName,
|
|
@@ -6790,7 +6805,7 @@ var OpenAITranscriptionModel = class {
|
|
|
6790
6805
|
};
|
|
6791
6806
|
|
|
6792
6807
|
// src/version.ts
|
|
6793
|
-
var VERSION = true ? "3.0.
|
|
6808
|
+
var VERSION = true ? "3.0.65" : "0.0.0-test";
|
|
6794
6809
|
|
|
6795
6810
|
// src/openai-provider.ts
|
|
6796
6811
|
function createOpenAI(options = {}) {
|