@ai-sdk/openai 4.0.17 → 4.0.19
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.js +39 -22
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +2 -1
- package/dist/internal/index.js +39 -21
- package/dist/internal/index.js.map +1 -1
- package/package.json +1 -1
- package/src/image/openai-image-model-options.ts +8 -7
- package/src/image/openai-image-model.ts +2 -2
- package/src/openai-language-model-capabilities.ts +47 -22
- package/src/responses/convert-to-openai-responses-input.ts +9 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 34c53c0: Apply reasoning, service tier, and image defaults to recognizable future OpenAI model family versions.
|
|
8
|
+
|
|
9
|
+
## 4.0.18
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- bc43dc2: Preserve stored tool search output item IDs from provider metadata.
|
|
14
|
+
|
|
3
15
|
## 4.0.17
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -43,10 +43,15 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
43
43
|
|
|
44
44
|
// src/openai-language-model-capabilities.ts
|
|
45
45
|
function getOpenAILanguageModelCapabilities(modelId) {
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
46
|
+
var _a, _b, _c, _d, _e;
|
|
47
|
+
const oSeriesVersion = getOSeriesVersion(modelId);
|
|
48
|
+
const gptVersion = getGptVersion(modelId);
|
|
49
|
+
const isGptChatModel = (gptVersion == null ? void 0 : gptVersion.minor) == null && ((_b = (_a = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _a.startsWith("chat")) != null ? _b : false);
|
|
50
|
+
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
51
|
+
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
52
|
+
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
53
|
+
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
54
|
+
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
50
55
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
51
56
|
return {
|
|
52
57
|
supportsFlexProcessing,
|
|
@@ -56,6 +61,21 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
56
61
|
supportsNonReasoningParameters
|
|
57
62
|
};
|
|
58
63
|
}
|
|
64
|
+
function getOSeriesVersion(modelId) {
|
|
65
|
+
const match = /^o(\d+)(?:-|$)/.exec(modelId);
|
|
66
|
+
return match == null ? void 0 : Number(match[1]);
|
|
67
|
+
}
|
|
68
|
+
function getGptVersion(modelId) {
|
|
69
|
+
const match = /^gpt-(\d+)(?:\.(\d+))?(?:-(.+))?$/.exec(modelId);
|
|
70
|
+
if (match == null) {
|
|
71
|
+
return void 0;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
major: Number(match[1]),
|
|
75
|
+
minor: match[2] == null ? void 0 : Number(match[2]),
|
|
76
|
+
variant: match[3]
|
|
77
|
+
};
|
|
78
|
+
}
|
|
59
79
|
|
|
60
80
|
// src/openai-stream-error.ts
|
|
61
81
|
import { APICallError } from "@ai-sdk/provider";
|
|
@@ -2136,18 +2156,16 @@ var modelMaxImagesPerCall = {
|
|
|
2136
2156
|
"gpt-image-2": 10,
|
|
2137
2157
|
"chatgpt-image-latest": 10
|
|
2138
2158
|
};
|
|
2139
|
-
var defaultResponseFormatPrefixes = [
|
|
2140
|
-
"chatgpt-image-",
|
|
2141
|
-
"gpt-image-1-mini",
|
|
2142
|
-
"gpt-image-1.5",
|
|
2143
|
-
"gpt-image-1",
|
|
2144
|
-
"gpt-image-2"
|
|
2145
|
-
];
|
|
2159
|
+
var defaultResponseFormatPrefixes = ["chatgpt-image-", "gpt-image-"];
|
|
2146
2160
|
function hasDefaultResponseFormat(modelId) {
|
|
2147
2161
|
return defaultResponseFormatPrefixes.some(
|
|
2148
2162
|
(prefix) => modelId.startsWith(prefix)
|
|
2149
2163
|
);
|
|
2150
2164
|
}
|
|
2165
|
+
function getMaxImagesPerCall(modelId) {
|
|
2166
|
+
var _a;
|
|
2167
|
+
return (_a = modelMaxImagesPerCall[modelId]) != null ? _a : modelId.startsWith("gpt-image-") ? 10 : 1;
|
|
2168
|
+
}
|
|
2151
2169
|
var baseImageModelOptionsObject = z11.object({
|
|
2152
2170
|
/**
|
|
2153
2171
|
* Quality of the generated image(s).
|
|
@@ -2225,8 +2243,7 @@ var OpenAIImageModel = class _OpenAIImageModel {
|
|
|
2225
2243
|
return new _OpenAIImageModel(options.modelId, options.config);
|
|
2226
2244
|
}
|
|
2227
2245
|
get maxImagesPerCall() {
|
|
2228
|
-
|
|
2229
|
-
return (_a = modelMaxImagesPerCall[this.modelId]) != null ? _a : 1;
|
|
2246
|
+
return getMaxImagesPerCall(this.modelId);
|
|
2230
2247
|
}
|
|
2231
2248
|
get provider() {
|
|
2232
2249
|
return this.config.provider;
|
|
@@ -3706,7 +3723,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3706
3723
|
hasComputerTool = false,
|
|
3707
3724
|
customProviderToolNames
|
|
3708
3725
|
}) {
|
|
3709
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
3726
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
|
|
3710
3727
|
let input = [];
|
|
3711
3728
|
const warnings = [];
|
|
3712
3729
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
@@ -4065,7 +4082,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4065
4082
|
part.toolName
|
|
4066
4083
|
);
|
|
4067
4084
|
if (resolvedResultToolName === "tool_search") {
|
|
4068
|
-
const itemId = (
|
|
4085
|
+
const itemId = (_s = (_r = (_o = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.itemId) != null ? _r : (_q = (_p = part.providerMetadata) == null ? void 0 : _p[providerOptionsName]) == null ? void 0 : _q.itemId) != null ? _s : part.toolCallId;
|
|
4069
4086
|
if (store) {
|
|
4070
4087
|
input.push({ type: "item_reference", id: itemId });
|
|
4071
4088
|
} else if (part.output.type === "json") {
|
|
@@ -4106,7 +4123,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4106
4123
|
break;
|
|
4107
4124
|
}
|
|
4108
4125
|
if (store) {
|
|
4109
|
-
const itemId = (
|
|
4126
|
+
const itemId = (_v = (_u = (_t = part.providerOptions) == null ? void 0 : _t[providerOptionsName]) == null ? void 0 : _u.itemId) != null ? _v : part.toolCallId;
|
|
4110
4127
|
input.push({ type: "item_reference", id: itemId });
|
|
4111
4128
|
} else {
|
|
4112
4129
|
warnings.push({
|
|
@@ -4191,7 +4208,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4191
4208
|
}
|
|
4192
4209
|
case "custom": {
|
|
4193
4210
|
if (part.kind === "openai.compaction") {
|
|
4194
|
-
const providerOptions2 = (
|
|
4211
|
+
const providerOptions2 = (_w = part.providerOptions) == null ? void 0 : _w[providerOptionsName];
|
|
4195
4212
|
const id = providerOptions2 == null ? void 0 : providerOptions2.itemId;
|
|
4196
4213
|
if (hasConversation && id != null) {
|
|
4197
4214
|
break;
|
|
@@ -4238,7 +4255,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4238
4255
|
}
|
|
4239
4256
|
const output = part.output;
|
|
4240
4257
|
if (output.type === "execution-denied") {
|
|
4241
|
-
const approvalId = (
|
|
4258
|
+
const approvalId = (_y = (_x = output.providerOptions) == null ? void 0 : _x.openai) == null ? void 0 : _y.approvalId;
|
|
4242
4259
|
if (approvalId) {
|
|
4243
4260
|
continue;
|
|
4244
4261
|
}
|
|
@@ -4318,7 +4335,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4318
4335
|
file_id: parsedOutput.output.fileId,
|
|
4319
4336
|
detail: parsedOutput.output.detail
|
|
4320
4337
|
},
|
|
4321
|
-
acknowledged_safety_checks: (
|
|
4338
|
+
acknowledged_safety_checks: (_z = parsedOutput.acknowledgedSafetyChecks) == null ? void 0 : _z.map((safetyCheck) => ({
|
|
4322
4339
|
id: safetyCheck.id,
|
|
4323
4340
|
code: safetyCheck.code,
|
|
4324
4341
|
message: safetyCheck.message
|
|
@@ -4334,7 +4351,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4334
4351
|
outputValue = output.value;
|
|
4335
4352
|
break;
|
|
4336
4353
|
case "execution-denied":
|
|
4337
|
-
outputValue = (
|
|
4354
|
+
outputValue = (_A = output.reason) != null ? _A : "Tool call execution denied.";
|
|
4338
4355
|
break;
|
|
4339
4356
|
case "json":
|
|
4340
4357
|
case "error-json":
|
|
@@ -4433,7 +4450,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4433
4450
|
contentValue = output.value;
|
|
4434
4451
|
break;
|
|
4435
4452
|
case "execution-denied":
|
|
4436
|
-
contentValue = (
|
|
4453
|
+
contentValue = (_B = output.reason) != null ? _B : "Tool call execution denied.";
|
|
4437
4454
|
break;
|
|
4438
4455
|
case "json":
|
|
4439
4456
|
case "error-json":
|
|
@@ -8873,7 +8890,7 @@ var OpenAISkills = class {
|
|
|
8873
8890
|
};
|
|
8874
8891
|
|
|
8875
8892
|
// src/version.ts
|
|
8876
|
-
var VERSION = true ? "4.0.
|
|
8893
|
+
var VERSION = true ? "4.0.19" : "0.0.0-test";
|
|
8877
8894
|
|
|
8878
8895
|
// src/openai-provider.ts
|
|
8879
8896
|
function createOpenAI(options = {}) {
|