@ai-sdk/gateway 4.0.91 → 4.0.94
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 +23 -0
- package/README.md +1 -1
- package/dist/index.d.ts +132 -11
- package/dist/index.js +257 -209
- package/dist/index.js.map +1 -1
- package/docs/00-ai-gateway.mdx +153 -26
- package/package.json +3 -3
- package/src/gateway-image-model-settings.ts +1 -0
- package/src/gateway-language-model-settings.ts +3 -1
- package/src/gateway-provider-options.ts +8 -6
- package/src/gateway-speech-model-settings.ts +1 -1
- package/src/gateway-tools.ts +18 -0
- package/src/tool/browserbase-fetch.ts +157 -0
- package/src/tool/browserbase-search.ts +137 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
|
+
lazySchema,
|
|
4
|
+
zodSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
6
|
+
import { z } from '../zod';
|
|
7
|
+
|
|
8
|
+
export interface BrowserbaseSearchConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Default maximum number of results to return (1-25, default: 10).
|
|
11
|
+
*/
|
|
12
|
+
numResults?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface BrowserbaseSearchInput {
|
|
16
|
+
/**
|
|
17
|
+
* Web search query (1-200 characters).
|
|
18
|
+
*/
|
|
19
|
+
query: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Maximum number of results to return (1-25, default: 10).
|
|
23
|
+
*/
|
|
24
|
+
num_results?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface BrowserbaseSearchResult {
|
|
28
|
+
/** Unique identifier for the result. */
|
|
29
|
+
id: string;
|
|
30
|
+
/** Title of the search result. */
|
|
31
|
+
title: string;
|
|
32
|
+
/** URL of the search result. */
|
|
33
|
+
url: string;
|
|
34
|
+
/** Author of the content, when available. */
|
|
35
|
+
author?: string;
|
|
36
|
+
/** Favicon URL, when available. */
|
|
37
|
+
favicon?: string;
|
|
38
|
+
/** Image URL, when available. */
|
|
39
|
+
image?: string;
|
|
40
|
+
/** Publication date in ISO 8601 format, when available. */
|
|
41
|
+
publishedDate?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface BrowserbaseSearchResponse {
|
|
45
|
+
/** The search query that was executed. */
|
|
46
|
+
query: string;
|
|
47
|
+
/** Unique identifier for the request. */
|
|
48
|
+
requestId: string;
|
|
49
|
+
/** Search results. */
|
|
50
|
+
results: BrowserbaseSearchResult[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface BrowserbaseSearchError {
|
|
54
|
+
error:
|
|
55
|
+
| 'api_error'
|
|
56
|
+
| 'configuration_error'
|
|
57
|
+
| 'execution_error'
|
|
58
|
+
| 'invalid_input'
|
|
59
|
+
| 'rate_limit'
|
|
60
|
+
| 'timeout'
|
|
61
|
+
| 'unknown';
|
|
62
|
+
statusCode?: number;
|
|
63
|
+
message: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type BrowserbaseSearchOutput =
|
|
67
|
+
| BrowserbaseSearchError
|
|
68
|
+
| BrowserbaseSearchResponse;
|
|
69
|
+
|
|
70
|
+
const browserbaseSearchInputSchema = lazySchema(() =>
|
|
71
|
+
zodSchema(
|
|
72
|
+
z.object({
|
|
73
|
+
query: z
|
|
74
|
+
.string()
|
|
75
|
+
.min(1)
|
|
76
|
+
.max(200)
|
|
77
|
+
.describe('Web search query. Must be between 1 and 200 characters.'),
|
|
78
|
+
num_results: z
|
|
79
|
+
.number()
|
|
80
|
+
.int()
|
|
81
|
+
.min(1)
|
|
82
|
+
.max(25)
|
|
83
|
+
.optional()
|
|
84
|
+
.describe('Maximum number of results to return (1-25, default: 10).'),
|
|
85
|
+
}),
|
|
86
|
+
),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const browserbaseSearchOutputSchema = lazySchema(() =>
|
|
90
|
+
zodSchema(
|
|
91
|
+
z.union([
|
|
92
|
+
z.object({
|
|
93
|
+
query: z.string(),
|
|
94
|
+
requestId: z.string(),
|
|
95
|
+
results: z.array(
|
|
96
|
+
z.object({
|
|
97
|
+
id: z.string(),
|
|
98
|
+
title: z.string(),
|
|
99
|
+
url: z.string(),
|
|
100
|
+
author: z.string().optional(),
|
|
101
|
+
favicon: z.string().optional(),
|
|
102
|
+
image: z.string().optional(),
|
|
103
|
+
publishedDate: z.string().optional(),
|
|
104
|
+
}),
|
|
105
|
+
),
|
|
106
|
+
}),
|
|
107
|
+
z.object({
|
|
108
|
+
error: z.enum([
|
|
109
|
+
'api_error',
|
|
110
|
+
'configuration_error',
|
|
111
|
+
'execution_error',
|
|
112
|
+
'invalid_input',
|
|
113
|
+
'rate_limit',
|
|
114
|
+
'timeout',
|
|
115
|
+
'unknown',
|
|
116
|
+
]),
|
|
117
|
+
statusCode: z.number().optional(),
|
|
118
|
+
message: z.string(),
|
|
119
|
+
}),
|
|
120
|
+
]),
|
|
121
|
+
),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
export const browserbaseSearchToolFactory = createProviderExecutedToolFactory<
|
|
125
|
+
BrowserbaseSearchInput,
|
|
126
|
+
BrowserbaseSearchOutput,
|
|
127
|
+
BrowserbaseSearchConfig
|
|
128
|
+
>({
|
|
129
|
+
id: 'gateway.browserbase_search',
|
|
130
|
+
inputSchema: browserbaseSearchInputSchema,
|
|
131
|
+
outputSchema: browserbaseSearchOutputSchema,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
export const browserbaseSearch = (
|
|
135
|
+
config: BrowserbaseSearchConfig = {},
|
|
136
|
+
): ReturnType<typeof browserbaseSearchToolFactory> =>
|
|
137
|
+
browserbaseSearchToolFactory(config);
|