@ai-sdk/openai 3.0.87 → 3.0.89
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.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +39 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -16
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +10 -1
- package/dist/internal/index.d.ts +10 -1
- package/dist/internal/index.js +40 -15
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +39 -15
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +5 -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/openai-responses-api.ts +6 -1
- package/src/responses/openai-responses-prepare-tools.ts +4 -1
- package/src/tool/web-search.ts +12 -1
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;
|
|
@@ -5105,7 +5122,10 @@ var webSearchArgsSchema = lazySchema23(
|
|
|
5105
5122
|
() => zodSchema23(
|
|
5106
5123
|
z25.object({
|
|
5107
5124
|
externalWebAccess: z25.boolean().optional(),
|
|
5108
|
-
filters: z25.object({
|
|
5125
|
+
filters: z25.object({
|
|
5126
|
+
allowedDomains: z25.array(z25.string()).optional(),
|
|
5127
|
+
blockedDomains: z25.array(z25.string()).optional()
|
|
5128
|
+
}).optional(),
|
|
5109
5129
|
searchContextSize: z25.enum(["low", "medium", "high"]).optional(),
|
|
5110
5130
|
userLocation: z25.object({
|
|
5111
5131
|
type: z25.literal("approximate"),
|
|
@@ -5315,7 +5335,10 @@ async function prepareResponsesTools({
|
|
|
5315
5335
|
});
|
|
5316
5336
|
openaiTools.push({
|
|
5317
5337
|
type: "web_search",
|
|
5318
|
-
filters: args.filters != null ? {
|
|
5338
|
+
filters: args.filters != null ? {
|
|
5339
|
+
allowed_domains: args.filters.allowedDomains,
|
|
5340
|
+
blocked_domains: args.filters.blockedDomains
|
|
5341
|
+
} : void 0,
|
|
5319
5342
|
external_web_access: args.externalWebAccess,
|
|
5320
5343
|
search_context_size: args.searchContextSize,
|
|
5321
5344
|
user_location: args.userLocation
|
|
@@ -7345,6 +7368,7 @@ export {
|
|
|
7345
7368
|
fileSearch,
|
|
7346
7369
|
fileSearchArgsSchema,
|
|
7347
7370
|
fileSearchOutputSchema,
|
|
7371
|
+
getMaxImagesPerCall,
|
|
7348
7372
|
hasDefaultResponseFormat,
|
|
7349
7373
|
imageGeneration,
|
|
7350
7374
|
imageGenerationArgsSchema,
|