@ai-sdk/openai 4.0.22 → 4.0.23
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.d.ts +7 -0
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +8 -0
- package/dist/internal/index.js +8 -2
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +5 -1
- package/package.json +1 -1
- 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/docs/03-openai.mdx
CHANGED
|
@@ -539,6 +539,7 @@ const result = await generateText({
|
|
|
539
539
|
},
|
|
540
540
|
filters: {
|
|
541
541
|
allowedDomains: ['sfchronicle.com', 'sfgate.com'],
|
|
542
|
+
blockedDomains: ['example.com'],
|
|
542
543
|
},
|
|
543
544
|
}),
|
|
544
545
|
},
|
|
@@ -565,7 +566,10 @@ The web search tool supports the following configuration options:
|
|
|
565
566
|
- **searchContextSize** _'low' | 'medium' | 'high'_ - Controls the amount of context used for the search. Higher values provide more comprehensive results but may have higher latency and cost.
|
|
566
567
|
- **userLocation** - Optional location information to provide geographically relevant results. Includes `type` (always `'approximate'`), `country`, `city`, `region`, and `timezone`.
|
|
567
568
|
- **filters** - Optional filter configuration to restrict search results.
|
|
568
|
-
- **allowedDomains** _string[]_ -
|
|
569
|
+
- **allowedDomains** _string[]_ - Up to 100 allowed domains for the search.
|
|
570
|
+
- **blockedDomains** _string[]_ - Up to 100 blocked domains for the search.
|
|
571
|
+
|
|
572
|
+
Omit the HTTP or HTTPS prefix from domain filters. Subdomains of configured domains are automatically included or excluded.
|
|
569
573
|
|
|
570
574
|
For detailed information on configuration options see the [OpenAI Web Search Tool documentation](https://platform.openai.com/docs/guides/tools-web-search?api-mode=responses).
|
|
571
575
|
|
package/package.json
CHANGED
|
@@ -497,7 +497,12 @@ export type OpenAIResponsesTool =
|
|
|
497
497
|
| {
|
|
498
498
|
type: 'web_search';
|
|
499
499
|
external_web_access: boolean | undefined;
|
|
500
|
-
filters:
|
|
500
|
+
filters:
|
|
501
|
+
| {
|
|
502
|
+
allowed_domains: string[] | undefined;
|
|
503
|
+
blocked_domains: string[] | undefined;
|
|
504
|
+
}
|
|
505
|
+
| undefined;
|
|
501
506
|
search_context_size: 'low' | 'medium' | 'high' | undefined;
|
|
502
507
|
user_location:
|
|
503
508
|
| {
|
|
@@ -204,7 +204,10 @@ export async function prepareResponsesTools({
|
|
|
204
204
|
type: 'web_search',
|
|
205
205
|
filters:
|
|
206
206
|
args.filters != null
|
|
207
|
-
? {
|
|
207
|
+
? {
|
|
208
|
+
allowed_domains: args.filters.allowedDomains,
|
|
209
|
+
blocked_domains: args.filters.blockedDomains,
|
|
210
|
+
}
|
|
208
211
|
: undefined,
|
|
209
212
|
external_web_access: args.externalWebAccess,
|
|
210
213
|
search_context_size: args.searchContextSize,
|
package/src/tool/web-search.ts
CHANGED
|
@@ -10,7 +10,10 @@ export const webSearchArgsSchema = lazySchema(() =>
|
|
|
10
10
|
z.object({
|
|
11
11
|
externalWebAccess: z.boolean().optional(),
|
|
12
12
|
filters: z
|
|
13
|
-
.object({
|
|
13
|
+
.object({
|
|
14
|
+
allowedDomains: z.array(z.string()).optional(),
|
|
15
|
+
blockedDomains: z.array(z.string()).optional(),
|
|
16
|
+
})
|
|
14
17
|
.optional(),
|
|
15
18
|
searchContextSize: z.enum(['low', 'medium', 'high']).optional(),
|
|
16
19
|
userLocation: z
|
|
@@ -140,8 +143,16 @@ export const webSearchToolFactory = createProviderExecutedToolFactory<
|
|
|
140
143
|
* Allowed domains for the search.
|
|
141
144
|
* If not provided, all domains are allowed.
|
|
142
145
|
* Subdomains of the provided domains are allowed as well.
|
|
146
|
+
* Omit the HTTP or HTTPS prefix. Maximum 100 domains.
|
|
143
147
|
*/
|
|
144
148
|
allowedDomains?: string[];
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Blocked domains for the search.
|
|
152
|
+
* Subdomains of the provided domains are blocked as well.
|
|
153
|
+
* Omit the HTTP or HTTPS prefix. Maximum 100 domains.
|
|
154
|
+
*/
|
|
155
|
+
blockedDomains?: string[];
|
|
145
156
|
};
|
|
146
157
|
|
|
147
158
|
/**
|