@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 3.0.89
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 23632b1: Add blocked domain filters to the OpenAI and Azure Responses API web search tools.
|
|
8
|
+
|
|
9
|
+
## 3.0.88
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 8100830: Apply reasoning, service tier, and image defaults to recognizable future OpenAI model family versions.
|
|
14
|
+
|
|
3
15
|
## 3.0.87
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -143,8 +143,15 @@ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
|
|
|
143
143
|
* Allowed domains for the search.
|
|
144
144
|
* If not provided, all domains are allowed.
|
|
145
145
|
* Subdomains of the provided domains are allowed as well.
|
|
146
|
+
* Omit the HTTP or HTTPS prefix. Maximum 100 domains.
|
|
146
147
|
*/
|
|
147
148
|
allowedDomains?: string[];
|
|
149
|
+
/**
|
|
150
|
+
* Blocked domains for the search.
|
|
151
|
+
* Subdomains of the provided domains are blocked as well.
|
|
152
|
+
* Omit the HTTP or HTTPS prefix. Maximum 100 domains.
|
|
153
|
+
*/
|
|
154
|
+
blockedDomains?: string[];
|
|
148
155
|
};
|
|
149
156
|
/**
|
|
150
157
|
* Search context size to use for the web search.
|
package/dist/index.d.ts
CHANGED
|
@@ -143,8 +143,15 @@ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
|
|
|
143
143
|
* Allowed domains for the search.
|
|
144
144
|
* If not provided, all domains are allowed.
|
|
145
145
|
* Subdomains of the provided domains are allowed as well.
|
|
146
|
+
* Omit the HTTP or HTTPS prefix. Maximum 100 domains.
|
|
146
147
|
*/
|
|
147
148
|
allowedDomains?: string[];
|
|
149
|
+
/**
|
|
150
|
+
* Blocked domains for the search.
|
|
151
|
+
* Subdomains of the provided domains are blocked as well.
|
|
152
|
+
* Omit the HTTP or HTTPS prefix. Maximum 100 domains.
|
|
153
|
+
*/
|
|
154
|
+
blockedDomains?: string[];
|
|
148
155
|
};
|
|
149
156
|
/**
|
|
150
157
|
* Search context size to use for the web search.
|
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;
|
|
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/openai-stream-error.ts
|
|
72
92
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -1986,18 +2006,16 @@ var modelMaxImagesPerCall = {
|
|
|
1986
2006
|
"gpt-image-2": 10,
|
|
1987
2007
|
"chatgpt-image-latest": 10
|
|
1988
2008
|
};
|
|
1989
|
-
var defaultResponseFormatPrefixes = [
|
|
1990
|
-
"chatgpt-image-",
|
|
1991
|
-
"gpt-image-1-mini",
|
|
1992
|
-
"gpt-image-1.5",
|
|
1993
|
-
"gpt-image-1",
|
|
1994
|
-
"gpt-image-2"
|
|
1995
|
-
];
|
|
2009
|
+
var defaultResponseFormatPrefixes = ["chatgpt-image-", "gpt-image-"];
|
|
1996
2010
|
function hasDefaultResponseFormat(modelId) {
|
|
1997
2011
|
return defaultResponseFormatPrefixes.some(
|
|
1998
2012
|
(prefix) => modelId.startsWith(prefix)
|
|
1999
2013
|
);
|
|
2000
2014
|
}
|
|
2015
|
+
function getMaxImagesPerCall(modelId) {
|
|
2016
|
+
var _a;
|
|
2017
|
+
return (_a = modelMaxImagesPerCall[modelId]) != null ? _a : modelId.startsWith("gpt-image-") ? 10 : 1;
|
|
2018
|
+
}
|
|
2001
2019
|
var baseImageModelOptionsObject = import_v49.z.object({
|
|
2002
2020
|
/**
|
|
2003
2021
|
* Quality of the generated image(s).
|
|
@@ -2066,8 +2084,7 @@ var OpenAIImageModel = class {
|
|
|
2066
2084
|
this.specificationVersion = "v3";
|
|
2067
2085
|
}
|
|
2068
2086
|
get maxImagesPerCall() {
|
|
2069
|
-
|
|
2070
|
-
return (_a = modelMaxImagesPerCall[this.modelId]) != null ? _a : 1;
|
|
2087
|
+
return getMaxImagesPerCall(this.modelId);
|
|
2071
2088
|
}
|
|
2072
2089
|
get provider() {
|
|
2073
2090
|
return this.config.provider;
|
|
@@ -2634,7 +2651,10 @@ var webSearchArgsSchema = (0, import_provider_utils23.lazySchema)(
|
|
|
2634
2651
|
() => (0, import_provider_utils23.zodSchema)(
|
|
2635
2652
|
import_v418.z.object({
|
|
2636
2653
|
externalWebAccess: import_v418.z.boolean().optional(),
|
|
2637
|
-
filters: import_v418.z.object({
|
|
2654
|
+
filters: import_v418.z.object({
|
|
2655
|
+
allowedDomains: import_v418.z.array(import_v418.z.string()).optional(),
|
|
2656
|
+
blockedDomains: import_v418.z.array(import_v418.z.string()).optional()
|
|
2657
|
+
}).optional(),
|
|
2638
2658
|
searchContextSize: import_v418.z.enum(["low", "medium", "high"]).optional(),
|
|
2639
2659
|
userLocation: import_v418.z.object({
|
|
2640
2660
|
type: import_v418.z.literal("approximate"),
|
|
@@ -4967,7 +4987,10 @@ async function prepareResponsesTools({
|
|
|
4967
4987
|
});
|
|
4968
4988
|
openaiTools2.push({
|
|
4969
4989
|
type: "web_search",
|
|
4970
|
-
filters: args.filters != null ? {
|
|
4990
|
+
filters: args.filters != null ? {
|
|
4991
|
+
allowed_domains: args.filters.allowedDomains,
|
|
4992
|
+
blocked_domains: args.filters.blockedDomains
|
|
4993
|
+
} : void 0,
|
|
4971
4994
|
external_web_access: args.externalWebAccess,
|
|
4972
4995
|
search_context_size: args.searchContextSize,
|
|
4973
4996
|
user_location: args.userLocation
|
|
@@ -7330,7 +7353,7 @@ var OpenAITranscriptionModel = class {
|
|
|
7330
7353
|
};
|
|
7331
7354
|
|
|
7332
7355
|
// src/version.ts
|
|
7333
|
-
var VERSION = true ? "3.0.
|
|
7356
|
+
var VERSION = true ? "3.0.89" : "0.0.0-test";
|
|
7334
7357
|
|
|
7335
7358
|
// src/openai-provider.ts
|
|
7336
7359
|
function createOpenAI(options = {}) {
|