@ai-sdk/openai 2.0.114 → 2.0.115
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.js +37 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -14
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +3 -2
- package/dist/internal/index.d.ts +3 -2
- package/dist/internal/index.js +38 -13
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +37 -13
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -54,10 +54,15 @@ var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
|
|
|
54
54
|
|
|
55
55
|
// src/openai-language-model-capabilities.ts
|
|
56
56
|
function getOpenAILanguageModelCapabilities(modelId) {
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const
|
|
57
|
+
var _a, _b, _c, _d, _e;
|
|
58
|
+
const oSeriesVersion = getOSeriesVersion(modelId);
|
|
59
|
+
const gptVersion = getGptVersion(modelId);
|
|
60
|
+
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);
|
|
61
|
+
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
62
|
+
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
63
|
+
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
64
|
+
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel || modelId === "codex-mini-latest" || modelId === "computer-use-preview";
|
|
65
|
+
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
61
66
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
62
67
|
return {
|
|
63
68
|
supportsFlexProcessing,
|
|
@@ -67,6 +72,21 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
67
72
|
supportsNonReasoningParameters
|
|
68
73
|
};
|
|
69
74
|
}
|
|
75
|
+
function getOSeriesVersion(modelId) {
|
|
76
|
+
const match = /^o(\d+)(?:-|$)/.exec(modelId);
|
|
77
|
+
return match == null ? void 0 : Number(match[1]);
|
|
78
|
+
}
|
|
79
|
+
function getGptVersion(modelId) {
|
|
80
|
+
const match = /^gpt-(\d+)(?:\.(\d+))?(?:-(.+))?$/.exec(modelId);
|
|
81
|
+
if (match == null) {
|
|
82
|
+
return void 0;
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
major: Number(match[1]),
|
|
86
|
+
minor: match[2] == null ? void 0 : Number(match[2]),
|
|
87
|
+
variant: match[3]
|
|
88
|
+
};
|
|
89
|
+
}
|
|
70
90
|
|
|
71
91
|
// src/chat/convert-to-openai-chat-messages.ts
|
|
72
92
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -1768,12 +1788,16 @@ var modelMaxImagesPerCall = {
|
|
|
1768
1788
|
"gpt-image-1.5": 10,
|
|
1769
1789
|
"gpt-image-2": 10
|
|
1770
1790
|
};
|
|
1771
|
-
var
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1791
|
+
var defaultResponseFormatPrefixes = ["gpt-image-"];
|
|
1792
|
+
function hasDefaultResponseFormat(modelId) {
|
|
1793
|
+
return defaultResponseFormatPrefixes.some(
|
|
1794
|
+
(prefix) => modelId.startsWith(prefix)
|
|
1795
|
+
);
|
|
1796
|
+
}
|
|
1797
|
+
function getMaxImagesPerCall(modelId) {
|
|
1798
|
+
var _a;
|
|
1799
|
+
return (_a = modelMaxImagesPerCall[modelId]) != null ? _a : modelId.startsWith("gpt-image-") ? 10 : 1;
|
|
1800
|
+
}
|
|
1777
1801
|
var baseImageModelOptionsObject = import_v49.z.object({
|
|
1778
1802
|
/**
|
|
1779
1803
|
* Quality of the generated image(s).
|
|
@@ -1832,8 +1856,7 @@ var OpenAIImageModel = class {
|
|
|
1832
1856
|
this.specificationVersion = "v2";
|
|
1833
1857
|
}
|
|
1834
1858
|
get maxImagesPerCall() {
|
|
1835
|
-
|
|
1836
|
-
return (_a = modelMaxImagesPerCall[this.modelId]) != null ? _a : 1;
|
|
1859
|
+
return getMaxImagesPerCall(this.modelId);
|
|
1837
1860
|
}
|
|
1838
1861
|
get provider() {
|
|
1839
1862
|
return this.config.provider;
|
|
@@ -1884,7 +1907,7 @@ var OpenAIImageModel = class {
|
|
|
1884
1907
|
output_format: openaiOptions.outputFormat,
|
|
1885
1908
|
output_compression: openaiOptions.outputCompression,
|
|
1886
1909
|
user: openaiOptions.user,
|
|
1887
|
-
...!hasDefaultResponseFormat
|
|
1910
|
+
...!hasDefaultResponseFormat(this.modelId) ? { response_format: "b64_json" } : {}
|
|
1888
1911
|
},
|
|
1889
1912
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1890
1913
|
successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
|
|
@@ -4973,7 +4996,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4973
4996
|
};
|
|
4974
4997
|
|
|
4975
4998
|
// src/version.ts
|
|
4976
|
-
var VERSION = true ? "2.0.
|
|
4999
|
+
var VERSION = true ? "2.0.115" : "0.0.0-test";
|
|
4977
5000
|
|
|
4978
5001
|
// src/openai-provider.ts
|
|
4979
5002
|
function createOpenAI(options = {}) {
|