@ai-sdk/openai 3.0.87 → 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 +6 -0
- package/dist/index.js +31 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -14
- 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 +32 -13
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +31 -13
- 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/dist/internal/index.mjs
CHANGED
|
@@ -32,10 +32,15 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
32
32
|
|
|
33
33
|
// src/openai-language-model-capabilities.ts
|
|
34
34
|
function getOpenAILanguageModelCapabilities(modelId) {
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
35
|
+
var _a, _b, _c, _d, _e;
|
|
36
|
+
const oSeriesVersion = getOSeriesVersion(modelId);
|
|
37
|
+
const gptVersion = getGptVersion(modelId);
|
|
38
|
+
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);
|
|
39
|
+
const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
|
|
40
|
+
const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
41
|
+
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
|
|
42
|
+
const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
|
|
43
|
+
const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
|
|
39
44
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
40
45
|
return {
|
|
41
46
|
supportsFlexProcessing,
|
|
@@ -45,6 +50,21 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
45
50
|
supportsNonReasoningParameters
|
|
46
51
|
};
|
|
47
52
|
}
|
|
53
|
+
function getOSeriesVersion(modelId) {
|
|
54
|
+
const match = /^o(\d+)(?:-|$)/.exec(modelId);
|
|
55
|
+
return match == null ? void 0 : Number(match[1]);
|
|
56
|
+
}
|
|
57
|
+
function getGptVersion(modelId) {
|
|
58
|
+
const match = /^gpt-(\d+)(?:\.(\d+))?(?:-(.+))?$/.exec(modelId);
|
|
59
|
+
if (match == null) {
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
major: Number(match[1]),
|
|
64
|
+
minor: match[2] == null ? void 0 : Number(match[2]),
|
|
65
|
+
variant: match[3]
|
|
66
|
+
};
|
|
67
|
+
}
|
|
48
68
|
|
|
49
69
|
// src/openai-stream-error.ts
|
|
50
70
|
import { APICallError } from "@ai-sdk/provider";
|
|
@@ -2011,18 +2031,16 @@ var modelMaxImagesPerCall = {
|
|
|
2011
2031
|
"gpt-image-2": 10,
|
|
2012
2032
|
"chatgpt-image-latest": 10
|
|
2013
2033
|
};
|
|
2014
|
-
var defaultResponseFormatPrefixes = [
|
|
2015
|
-
"chatgpt-image-",
|
|
2016
|
-
"gpt-image-1-mini",
|
|
2017
|
-
"gpt-image-1.5",
|
|
2018
|
-
"gpt-image-1",
|
|
2019
|
-
"gpt-image-2"
|
|
2020
|
-
];
|
|
2034
|
+
var defaultResponseFormatPrefixes = ["chatgpt-image-", "gpt-image-"];
|
|
2021
2035
|
function hasDefaultResponseFormat(modelId) {
|
|
2022
2036
|
return defaultResponseFormatPrefixes.some(
|
|
2023
2037
|
(prefix) => modelId.startsWith(prefix)
|
|
2024
2038
|
);
|
|
2025
2039
|
}
|
|
2040
|
+
function getMaxImagesPerCall(modelId) {
|
|
2041
|
+
var _a;
|
|
2042
|
+
return (_a = modelMaxImagesPerCall[modelId]) != null ? _a : modelId.startsWith("gpt-image-") ? 10 : 1;
|
|
2043
|
+
}
|
|
2026
2044
|
var baseImageModelOptionsObject = z9.object({
|
|
2027
2045
|
/**
|
|
2028
2046
|
* Quality of the generated image(s).
|
|
@@ -2091,8 +2109,7 @@ var OpenAIImageModel = class {
|
|
|
2091
2109
|
this.specificationVersion = "v3";
|
|
2092
2110
|
}
|
|
2093
2111
|
get maxImagesPerCall() {
|
|
2094
|
-
|
|
2095
|
-
return (_a = modelMaxImagesPerCall[this.modelId]) != null ? _a : 1;
|
|
2112
|
+
return getMaxImagesPerCall(this.modelId);
|
|
2096
2113
|
}
|
|
2097
2114
|
get provider() {
|
|
2098
2115
|
return this.config.provider;
|
|
@@ -7345,6 +7362,7 @@ export {
|
|
|
7345
7362
|
fileSearch,
|
|
7346
7363
|
fileSearchArgsSchema,
|
|
7347
7364
|
fileSearchOutputSchema,
|
|
7365
|
+
getMaxImagesPerCall,
|
|
7348
7366
|
hasDefaultResponseFormat,
|
|
7349
7367
|
imageGeneration,
|
|
7350
7368
|
imageGenerationArgsSchema,
|