@ai-sdk/openai 3.0.86 → 3.0.88
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 +37 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -20
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -1
- package/dist/internal/index.d.ts +2 -1
- package/dist/internal/index.js +38 -19
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +37 -19
- package/dist/internal/index.mjs.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/dist/index.mjs
CHANGED
|
@@ -40,10 +40,15 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
40
40
|
|
|
41
41
|
// src/openai-language-model-capabilities.ts
|
|
42
42
|
function getOpenAILanguageModelCapabilities(modelId) {
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
43
|
+
var _a, _b, _c, _d, _e;
|
|
44
|
+
const oSeriesVersion = getOSeriesVersion(modelId);
|
|
45
|
+
const gptVersion = getGptVersion(modelId);
|
|
46
|
+
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);
|
|
47
|
+
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
48
|
+
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
49
|
+
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
50
|
+
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
51
|
+
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
47
52
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
48
53
|
return {
|
|
49
54
|
supportsFlexProcessing,
|
|
@@ -53,6 +58,21 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
53
58
|
supportsNonReasoningParameters
|
|
54
59
|
};
|
|
55
60
|
}
|
|
61
|
+
function getOSeriesVersion(modelId) {
|
|
62
|
+
const match = /^o(\d+)(?:-|$)/.exec(modelId);
|
|
63
|
+
return match == null ? void 0 : Number(match[1]);
|
|
64
|
+
}
|
|
65
|
+
function getGptVersion(modelId) {
|
|
66
|
+
const match = /^gpt-(\d+)(?:\.(\d+))?(?:-(.+))?$/.exec(modelId);
|
|
67
|
+
if (match == null) {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
major: Number(match[1]),
|
|
72
|
+
minor: match[2] == null ? void 0 : Number(match[2]),
|
|
73
|
+
variant: match[3]
|
|
74
|
+
};
|
|
75
|
+
}
|
|
56
76
|
|
|
57
77
|
// src/openai-stream-error.ts
|
|
58
78
|
import { APICallError } from "@ai-sdk/provider";
|
|
@@ -2019,18 +2039,16 @@ var modelMaxImagesPerCall = {
|
|
|
2019
2039
|
"gpt-image-2": 10,
|
|
2020
2040
|
"chatgpt-image-latest": 10
|
|
2021
2041
|
};
|
|
2022
|
-
var defaultResponseFormatPrefixes = [
|
|
2023
|
-
"chatgpt-image-",
|
|
2024
|
-
"gpt-image-1-mini",
|
|
2025
|
-
"gpt-image-1.5",
|
|
2026
|
-
"gpt-image-1",
|
|
2027
|
-
"gpt-image-2"
|
|
2028
|
-
];
|
|
2042
|
+
var defaultResponseFormatPrefixes = ["chatgpt-image-", "gpt-image-"];
|
|
2029
2043
|
function hasDefaultResponseFormat(modelId) {
|
|
2030
2044
|
return defaultResponseFormatPrefixes.some(
|
|
2031
2045
|
(prefix) => modelId.startsWith(prefix)
|
|
2032
2046
|
);
|
|
2033
2047
|
}
|
|
2048
|
+
function getMaxImagesPerCall(modelId) {
|
|
2049
|
+
var _a;
|
|
2050
|
+
return (_a = modelMaxImagesPerCall[modelId]) != null ? _a : modelId.startsWith("gpt-image-") ? 10 : 1;
|
|
2051
|
+
}
|
|
2034
2052
|
var baseImageModelOptionsObject = z9.object({
|
|
2035
2053
|
/**
|
|
2036
2054
|
* Quality of the generated image(s).
|
|
@@ -2099,8 +2117,7 @@ var OpenAIImageModel = class {
|
|
|
2099
2117
|
this.specificationVersion = "v3";
|
|
2100
2118
|
}
|
|
2101
2119
|
get maxImagesPerCall() {
|
|
2102
|
-
|
|
2103
|
-
return (_a = modelMaxImagesPerCall[this.modelId]) != null ? _a : 1;
|
|
2120
|
+
return getMaxImagesPerCall(this.modelId);
|
|
2104
2121
|
}
|
|
2105
2122
|
get provider() {
|
|
2106
2123
|
return this.config.provider;
|
|
@@ -3079,7 +3096,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3079
3096
|
hasApplyPatchTool = false,
|
|
3080
3097
|
customProviderToolNames
|
|
3081
3098
|
}) {
|
|
3082
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
3099
|
+
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;
|
|
3083
3100
|
let input = [];
|
|
3084
3101
|
const warnings = [];
|
|
3085
3102
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
@@ -3356,7 +3373,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3356
3373
|
part.toolName
|
|
3357
3374
|
);
|
|
3358
3375
|
if (resolvedResultToolName === "tool_search") {
|
|
3359
|
-
const itemId = (
|
|
3376
|
+
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;
|
|
3360
3377
|
if (store) {
|
|
3361
3378
|
input.push({ type: "item_reference", id: itemId });
|
|
3362
3379
|
} else if (part.output.type === "json") {
|
|
@@ -3397,7 +3414,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3397
3414
|
break;
|
|
3398
3415
|
}
|
|
3399
3416
|
if (store) {
|
|
3400
|
-
const itemId = (
|
|
3417
|
+
const itemId = (_v = (_u = (_t = part.providerOptions) == null ? void 0 : _t[providerOptionsName]) == null ? void 0 : _u.itemId) != null ? _v : part.toolCallId;
|
|
3401
3418
|
input.push({ type: "item_reference", id: itemId });
|
|
3402
3419
|
} else {
|
|
3403
3420
|
warnings.push({
|
|
@@ -3507,7 +3524,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3507
3524
|
}
|
|
3508
3525
|
const output = part.output;
|
|
3509
3526
|
if (output.type === "execution-denied") {
|
|
3510
|
-
const approvalId = (
|
|
3527
|
+
const approvalId = (_x = (_w = output.providerOptions) == null ? void 0 : _w.openai) == null ? void 0 : _x.approvalId;
|
|
3511
3528
|
if (approvalId) {
|
|
3512
3529
|
continue;
|
|
3513
3530
|
}
|
|
@@ -3581,7 +3598,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3581
3598
|
outputValue = output.value;
|
|
3582
3599
|
break;
|
|
3583
3600
|
case "execution-denied":
|
|
3584
|
-
outputValue = (
|
|
3601
|
+
outputValue = (_y = output.reason) != null ? _y : "Tool call execution denied.";
|
|
3585
3602
|
break;
|
|
3586
3603
|
case "json":
|
|
3587
3604
|
case "error-json":
|
|
@@ -3664,7 +3681,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3664
3681
|
contentValue = output.value;
|
|
3665
3682
|
break;
|
|
3666
3683
|
case "execution-denied":
|
|
3667
|
-
contentValue = (
|
|
3684
|
+
contentValue = (_z = output.reason) != null ? _z : "Tool call execution denied.";
|
|
3668
3685
|
break;
|
|
3669
3686
|
case "json":
|
|
3670
3687
|
case "error-json":
|
|
@@ -7451,7 +7468,7 @@ var OpenAITranscriptionModel = class {
|
|
|
7451
7468
|
};
|
|
7452
7469
|
|
|
7453
7470
|
// src/version.ts
|
|
7454
|
-
var VERSION = true ? "3.0.
|
|
7471
|
+
var VERSION = true ? "3.0.88" : "0.0.0-test";
|
|
7455
7472
|
|
|
7456
7473
|
// src/openai-provider.ts
|
|
7457
7474
|
function createOpenAI(options = {}) {
|