@ai-sdk/openai 2.0.113 → 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 +13 -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 +2 -2
package/dist/internal/index.mjs
CHANGED
|
@@ -33,10 +33,15 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
33
33
|
|
|
34
34
|
// src/openai-language-model-capabilities.ts
|
|
35
35
|
function getOpenAILanguageModelCapabilities(modelId) {
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
36
|
+
var _a, _b, _c, _d, _e;
|
|
37
|
+
const oSeriesVersion = getOSeriesVersion(modelId);
|
|
38
|
+
const gptVersion = getGptVersion(modelId);
|
|
39
|
+
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);
|
|
40
|
+
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
41
|
+
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
42
|
+
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
43
|
+
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel || modelId === "codex-mini-latest" || modelId === "computer-use-preview";
|
|
44
|
+
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
40
45
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
41
46
|
return {
|
|
42
47
|
supportsFlexProcessing,
|
|
@@ -46,6 +51,21 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
46
51
|
supportsNonReasoningParameters
|
|
47
52
|
};
|
|
48
53
|
}
|
|
54
|
+
function getOSeriesVersion(modelId) {
|
|
55
|
+
const match = /^o(\d+)(?:-|$)/.exec(modelId);
|
|
56
|
+
return match == null ? void 0 : Number(match[1]);
|
|
57
|
+
}
|
|
58
|
+
function getGptVersion(modelId) {
|
|
59
|
+
const match = /^gpt-(\d+)(?:\.(\d+))?(?:-(.+))?$/.exec(modelId);
|
|
60
|
+
if (match == null) {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
major: Number(match[1]),
|
|
65
|
+
minor: match[2] == null ? void 0 : Number(match[2]),
|
|
66
|
+
variant: match[3]
|
|
67
|
+
};
|
|
68
|
+
}
|
|
49
69
|
|
|
50
70
|
// src/chat/convert-to-openai-chat-messages.ts
|
|
51
71
|
import {
|
|
@@ -1790,12 +1810,16 @@ var modelMaxImagesPerCall = {
|
|
|
1790
1810
|
"gpt-image-1.5": 10,
|
|
1791
1811
|
"gpt-image-2": 10
|
|
1792
1812
|
};
|
|
1793
|
-
var
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1813
|
+
var defaultResponseFormatPrefixes = ["gpt-image-"];
|
|
1814
|
+
function hasDefaultResponseFormat(modelId) {
|
|
1815
|
+
return defaultResponseFormatPrefixes.some(
|
|
1816
|
+
(prefix) => modelId.startsWith(prefix)
|
|
1817
|
+
);
|
|
1818
|
+
}
|
|
1819
|
+
function getMaxImagesPerCall(modelId) {
|
|
1820
|
+
var _a;
|
|
1821
|
+
return (_a = modelMaxImagesPerCall[modelId]) != null ? _a : modelId.startsWith("gpt-image-") ? 10 : 1;
|
|
1822
|
+
}
|
|
1799
1823
|
var baseImageModelOptionsObject = z9.object({
|
|
1800
1824
|
/**
|
|
1801
1825
|
* Quality of the generated image(s).
|
|
@@ -1854,8 +1878,7 @@ var OpenAIImageModel = class {
|
|
|
1854
1878
|
this.specificationVersion = "v2";
|
|
1855
1879
|
}
|
|
1856
1880
|
get maxImagesPerCall() {
|
|
1857
|
-
|
|
1858
|
-
return (_a = modelMaxImagesPerCall[this.modelId]) != null ? _a : 1;
|
|
1881
|
+
return getMaxImagesPerCall(this.modelId);
|
|
1859
1882
|
}
|
|
1860
1883
|
get provider() {
|
|
1861
1884
|
return this.config.provider;
|
|
@@ -1906,7 +1929,7 @@ var OpenAIImageModel = class {
|
|
|
1906
1929
|
output_format: openaiOptions.outputFormat,
|
|
1907
1930
|
output_compression: openaiOptions.outputCompression,
|
|
1908
1931
|
user: openaiOptions.user,
|
|
1909
|
-
...!hasDefaultResponseFormat
|
|
1932
|
+
...!hasDefaultResponseFormat(this.modelId) ? { response_format: "b64_json" } : {}
|
|
1910
1933
|
},
|
|
1911
1934
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1912
1935
|
successfulResponseHandler: createJsonResponseHandler4(
|
|
@@ -5004,6 +5027,7 @@ export {
|
|
|
5004
5027
|
fileSearch,
|
|
5005
5028
|
fileSearchArgsSchema,
|
|
5006
5029
|
fileSearchOutputSchema,
|
|
5030
|
+
getMaxImagesPerCall,
|
|
5007
5031
|
hasDefaultResponseFormat,
|
|
5008
5032
|
imageGeneration,
|
|
5009
5033
|
imageGenerationArgsSchema,
|