@ai-sdk/gateway 4.0.61 → 4.0.63
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 +14 -0
- package/dist/index.d.ts +234 -2
- package/dist/index.js +218 -2
- package/dist/index.js.map +1 -1
- package/docs/00-ai-gateway.mdx +106 -0
- package/package.json +3 -3
- package/src/gateway-language-model-settings.ts +1 -0
- package/src/gateway-tools.ts +11 -0
- package/src/gateway-video-model-settings.ts +1 -0
- package/src/tool/tako-search.ts +581 -0
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
|
+
lazySchema,
|
|
4
|
+
zodSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
6
|
+
import { z } from '../zod';
|
|
7
|
+
|
|
8
|
+
export type TakoSearchEffort = 'deep' | 'fast' | 'instant';
|
|
9
|
+
|
|
10
|
+
export type TakoContentFormat =
|
|
11
|
+
| 'card_json'
|
|
12
|
+
| 'csv'
|
|
13
|
+
| 'json_compact'
|
|
14
|
+
| 'json_records';
|
|
15
|
+
|
|
16
|
+
export interface TakoDataSourceConfig {
|
|
17
|
+
/** Maximum number of data cards to return (1-20). */
|
|
18
|
+
count?: number;
|
|
19
|
+
/** Inline underlying card data in the response. This can add a data charge. */
|
|
20
|
+
includeContents?: boolean;
|
|
21
|
+
/** Requested delivery mode for card data. Search cards are always inlined. */
|
|
22
|
+
mode?: 'inline' | 'url';
|
|
23
|
+
/** Serialization for inlined card data. */
|
|
24
|
+
contentFormat?: TakoContentFormat;
|
|
25
|
+
/** Maximum rows for inlined card data. The service clamps large values. */
|
|
26
|
+
maxRows?: number;
|
|
27
|
+
/** Data Graph node IDs to prioritize. */
|
|
28
|
+
nodeIds?: string[];
|
|
29
|
+
/** Return only cards matching nodeIds. Requires at least one node ID. */
|
|
30
|
+
strict?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface TakoWebSourceConfig {
|
|
34
|
+
/** Maximum number of web results to return (1-20). */
|
|
35
|
+
count?: number;
|
|
36
|
+
/** Inline extracted web page text. This can add a data charge. */
|
|
37
|
+
includeContents?: boolean;
|
|
38
|
+
/** Optional web-result category filter. */
|
|
39
|
+
category?: 'finance' | 'news' | 'sports';
|
|
40
|
+
/** Only return results from these bare domains. */
|
|
41
|
+
includeDomains?: string[];
|
|
42
|
+
/** Exclude results from these bare domains. */
|
|
43
|
+
excludeDomains?: string[];
|
|
44
|
+
/** Maximum characters in each web-result snippet. */
|
|
45
|
+
snippetMaxChars?: number;
|
|
46
|
+
/** Include highlighted passages in web results. Defaults to true in AI Gateway. */
|
|
47
|
+
highlights?: boolean;
|
|
48
|
+
/** Maximum extracted characters per web page when including contents. */
|
|
49
|
+
articleContentMaxChars?: number;
|
|
50
|
+
/** Keep results published on or after this ISO date. */
|
|
51
|
+
publishedAfter?: string;
|
|
52
|
+
/** Keep results published on or before this ISO date. */
|
|
53
|
+
publishedBefore?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface TakoSearchConfig {
|
|
57
|
+
/** Search effort. fast is the default balanced option. */
|
|
58
|
+
effort?: TakoSearchEffort;
|
|
59
|
+
/** Sources to search. Omit to search both curated data and the web. */
|
|
60
|
+
sources?: {
|
|
61
|
+
data?: TakoDataSourceConfig;
|
|
62
|
+
web?: TakoWebSourceConfig;
|
|
63
|
+
};
|
|
64
|
+
/** End-user coordinates for localized results. */
|
|
65
|
+
location?: {
|
|
66
|
+
latitude: number;
|
|
67
|
+
longitude: number;
|
|
68
|
+
};
|
|
69
|
+
/** ISO 3166-1 alpha-2 country code. */
|
|
70
|
+
countryCode?: string;
|
|
71
|
+
/** BCP-47 locale. */
|
|
72
|
+
locale?: string;
|
|
73
|
+
/** IANA timezone. */
|
|
74
|
+
timezone?: string;
|
|
75
|
+
/** Settings that control card rendering. */
|
|
76
|
+
outputSettings?: {
|
|
77
|
+
imageDarkMode?: boolean;
|
|
78
|
+
/** Instant-effort only. */
|
|
79
|
+
forceRefresh?: boolean;
|
|
80
|
+
};
|
|
81
|
+
/** Maximum related search suggestions to include (1-20). */
|
|
82
|
+
includeRelated?: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface TakoSearchInput {
|
|
86
|
+
query: string;
|
|
87
|
+
effort?: TakoSearchEffort;
|
|
88
|
+
sources?: {
|
|
89
|
+
data?: {
|
|
90
|
+
count?: number;
|
|
91
|
+
include_contents?: boolean;
|
|
92
|
+
mode?: 'inline' | 'url';
|
|
93
|
+
content_format?: TakoContentFormat;
|
|
94
|
+
max_rows?: number;
|
|
95
|
+
node_ids?: string[];
|
|
96
|
+
strict?: boolean;
|
|
97
|
+
};
|
|
98
|
+
web?: {
|
|
99
|
+
count?: number;
|
|
100
|
+
include_contents?: boolean;
|
|
101
|
+
category?: 'finance' | 'news' | 'sports';
|
|
102
|
+
include_domains?: string[];
|
|
103
|
+
exclude_domains?: string[];
|
|
104
|
+
snippet_max_chars?: number;
|
|
105
|
+
highlights?: boolean;
|
|
106
|
+
article_content_max_chars?: number;
|
|
107
|
+
published_after?: string;
|
|
108
|
+
published_before?: string;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
location?: {
|
|
112
|
+
latitude: number;
|
|
113
|
+
longitude: number;
|
|
114
|
+
};
|
|
115
|
+
country_code?: string;
|
|
116
|
+
locale?: string;
|
|
117
|
+
timezone?: string;
|
|
118
|
+
output_settings?: {
|
|
119
|
+
image_dark_mode?: boolean;
|
|
120
|
+
force_refresh?: boolean;
|
|
121
|
+
};
|
|
122
|
+
include_related?: number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export type TakoDatasetCell = boolean | number | string | null;
|
|
126
|
+
|
|
127
|
+
export interface TakoResultContent {
|
|
128
|
+
content_format?: TakoContentFormat | null;
|
|
129
|
+
cost?: number;
|
|
130
|
+
data?: string | null;
|
|
131
|
+
records?: Array<Record<string, TakoDatasetCell>> | null;
|
|
132
|
+
dataset?: {
|
|
133
|
+
columns: Array<{
|
|
134
|
+
name: string;
|
|
135
|
+
type: 'boolean' | 'date' | 'datetime' | 'number' | 'string';
|
|
136
|
+
unit?: string | null;
|
|
137
|
+
}>;
|
|
138
|
+
rows: TakoDatasetCell[][];
|
|
139
|
+
total_rows: number;
|
|
140
|
+
truncated: boolean;
|
|
141
|
+
ref: string;
|
|
142
|
+
sources: Array<{
|
|
143
|
+
name: string;
|
|
144
|
+
index?: 'data' | 'web';
|
|
145
|
+
}>;
|
|
146
|
+
provenance?: 'query' | 'web_extraction';
|
|
147
|
+
} | null;
|
|
148
|
+
card_data?: Record<string, unknown> | null;
|
|
149
|
+
card_data_schema?: Record<string, unknown> | null;
|
|
150
|
+
url?: string | null;
|
|
151
|
+
expires_at?: string | null;
|
|
152
|
+
total_rows?: number | null;
|
|
153
|
+
truncated?: boolean;
|
|
154
|
+
export_pricing?: {
|
|
155
|
+
baseline_usd: number;
|
|
156
|
+
free_rows: number;
|
|
157
|
+
max_rows_ceiling: number;
|
|
158
|
+
row_cpm_usd: number;
|
|
159
|
+
} | null;
|
|
160
|
+
manifest?: Array<{
|
|
161
|
+
dtype?: 'boolean' | 'date' | 'datetime' | 'number' | 'string' | null;
|
|
162
|
+
entity?: string | null;
|
|
163
|
+
metric?: string | null;
|
|
164
|
+
name?: string | null;
|
|
165
|
+
unit?: string | null;
|
|
166
|
+
}> | null;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface TakoCard {
|
|
170
|
+
card_id?: string | null;
|
|
171
|
+
title?: string | null;
|
|
172
|
+
description?: string | null;
|
|
173
|
+
semantic_description?: string | null;
|
|
174
|
+
webpage_url?: string | null;
|
|
175
|
+
image_url?: string | null;
|
|
176
|
+
embed_url?: string | null;
|
|
177
|
+
sources?: Array<{
|
|
178
|
+
source_name?: string | null;
|
|
179
|
+
source_description?: string | null;
|
|
180
|
+
source_index: 'data' | 'web';
|
|
181
|
+
source_text?: string | null;
|
|
182
|
+
url?: string | null;
|
|
183
|
+
}> | null;
|
|
184
|
+
methodologies?: Array<{
|
|
185
|
+
methodology_name: string | null;
|
|
186
|
+
methodology_description: string | null;
|
|
187
|
+
}> | null;
|
|
188
|
+
source_indexes?: Array<'data' | 'web'> | null;
|
|
189
|
+
card_type?: string | null;
|
|
190
|
+
relevance?: 'High' | 'Low' | 'Medium' | null;
|
|
191
|
+
content?: TakoResultContent | null;
|
|
192
|
+
exportable?: boolean;
|
|
193
|
+
relevance_score?: number | null;
|
|
194
|
+
nodes?: Array<{
|
|
195
|
+
id: string;
|
|
196
|
+
type: 'entity' | 'metric';
|
|
197
|
+
name: string;
|
|
198
|
+
description?: string | null;
|
|
199
|
+
}> | null;
|
|
200
|
+
metric_definitions?: Array<{
|
|
201
|
+
name: string;
|
|
202
|
+
definition: string;
|
|
203
|
+
}> | null;
|
|
204
|
+
data_freshness?: {
|
|
205
|
+
coverage_end?: string | null;
|
|
206
|
+
data_as_of?: string | null;
|
|
207
|
+
last_updated?: string | null;
|
|
208
|
+
} | null;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface TakoWebResult {
|
|
212
|
+
title: string;
|
|
213
|
+
url: string;
|
|
214
|
+
snippet?: string | null;
|
|
215
|
+
source_name?: string | null;
|
|
216
|
+
publish_date?: string | null;
|
|
217
|
+
content?: TakoResultContent | null;
|
|
218
|
+
citation_number?: number | null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface TakoSearchResponse {
|
|
222
|
+
request_id: string;
|
|
223
|
+
cards?: TakoCard[];
|
|
224
|
+
web_results?: TakoWebResult[];
|
|
225
|
+
usage?: {
|
|
226
|
+
total_cost_usd: number;
|
|
227
|
+
compute?: {
|
|
228
|
+
cost_usd: number;
|
|
229
|
+
} | null;
|
|
230
|
+
data?: {
|
|
231
|
+
cost_usd: number;
|
|
232
|
+
datasets: number;
|
|
233
|
+
} | null;
|
|
234
|
+
} | null;
|
|
235
|
+
related?: Array<Record<string, unknown>> | null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface TakoSearchError {
|
|
239
|
+
error:
|
|
240
|
+
| 'api_error'
|
|
241
|
+
| 'configuration_error'
|
|
242
|
+
| 'execution_error'
|
|
243
|
+
| 'invalid_input'
|
|
244
|
+
| 'rate_limit'
|
|
245
|
+
| 'timeout'
|
|
246
|
+
| 'unknown_tool';
|
|
247
|
+
statusCode?: number;
|
|
248
|
+
message: string;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export type TakoSearchOutput = TakoSearchError | TakoSearchResponse;
|
|
252
|
+
|
|
253
|
+
const takoDataSourceInputSchema = z.object({
|
|
254
|
+
count: z
|
|
255
|
+
.number()
|
|
256
|
+
.optional()
|
|
257
|
+
.describe('Maximum number of data cards to return (1-20).'),
|
|
258
|
+
include_contents: z
|
|
259
|
+
.boolean()
|
|
260
|
+
.optional()
|
|
261
|
+
.describe('Inline underlying card data. This can add a data charge.'),
|
|
262
|
+
mode: z
|
|
263
|
+
.enum(['inline', 'url'])
|
|
264
|
+
.optional()
|
|
265
|
+
.describe(
|
|
266
|
+
'Requested data delivery mode. Search card data is always inline.',
|
|
267
|
+
),
|
|
268
|
+
content_format: z
|
|
269
|
+
.enum(['card_json', 'csv', 'json_compact', 'json_records'])
|
|
270
|
+
.optional()
|
|
271
|
+
.describe('Serialization for inlined card data.'),
|
|
272
|
+
max_rows: z
|
|
273
|
+
.number()
|
|
274
|
+
.optional()
|
|
275
|
+
.describe('Maximum rows for inlined card data.'),
|
|
276
|
+
node_ids: z
|
|
277
|
+
.array(z.string())
|
|
278
|
+
.optional()
|
|
279
|
+
.describe('Data Graph node IDs to prioritize. Maximum 20.'),
|
|
280
|
+
strict: z
|
|
281
|
+
.boolean()
|
|
282
|
+
.optional()
|
|
283
|
+
.describe(
|
|
284
|
+
'Only return cards matching node_ids. Requires a non-empty node_ids.',
|
|
285
|
+
),
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
const takoWebSourceInputSchema = z.object({
|
|
289
|
+
count: z
|
|
290
|
+
.number()
|
|
291
|
+
.optional()
|
|
292
|
+
.describe('Maximum number of web results to return (1-20).'),
|
|
293
|
+
include_contents: z
|
|
294
|
+
.boolean()
|
|
295
|
+
.optional()
|
|
296
|
+
.describe('Inline extracted web page text. This can add a data charge.'),
|
|
297
|
+
category: z
|
|
298
|
+
.enum(['finance', 'news', 'sports'])
|
|
299
|
+
.optional()
|
|
300
|
+
.describe('Optional web-result category filter.'),
|
|
301
|
+
include_domains: z
|
|
302
|
+
.array(z.string())
|
|
303
|
+
.optional()
|
|
304
|
+
.describe('Only return results from these bare domains.'),
|
|
305
|
+
exclude_domains: z
|
|
306
|
+
.array(z.string())
|
|
307
|
+
.optional()
|
|
308
|
+
.describe('Exclude results from these bare domains.'),
|
|
309
|
+
snippet_max_chars: z
|
|
310
|
+
.number()
|
|
311
|
+
.optional()
|
|
312
|
+
.describe('Maximum characters in each web-result snippet.'),
|
|
313
|
+
highlights: z
|
|
314
|
+
.boolean()
|
|
315
|
+
.optional()
|
|
316
|
+
.describe(
|
|
317
|
+
'Include highlighted passages in web results. Defaults to true in AI Gateway.',
|
|
318
|
+
),
|
|
319
|
+
article_content_max_chars: z
|
|
320
|
+
.number()
|
|
321
|
+
.optional()
|
|
322
|
+
.describe(
|
|
323
|
+
'Maximum extracted characters per web page when including contents.',
|
|
324
|
+
),
|
|
325
|
+
published_after: z
|
|
326
|
+
.string()
|
|
327
|
+
.optional()
|
|
328
|
+
.describe('Keep results published on or after this ISO date (YYYY-MM-DD).'),
|
|
329
|
+
published_before: z
|
|
330
|
+
.string()
|
|
331
|
+
.optional()
|
|
332
|
+
.describe(
|
|
333
|
+
'Keep results published on or before this ISO date (YYYY-MM-DD).',
|
|
334
|
+
),
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
const takoSearchInputSchema = lazySchema(() =>
|
|
338
|
+
zodSchema(
|
|
339
|
+
z.object({
|
|
340
|
+
query: z
|
|
341
|
+
.string()
|
|
342
|
+
.describe(
|
|
343
|
+
'Natural-language search query. Include the entity, metric, and time period. Quote a phrase to force it to one entity, for example "Tesla":PRODUCT price.',
|
|
344
|
+
),
|
|
345
|
+
effort: z
|
|
346
|
+
.enum(['deep', 'fast', 'instant'])
|
|
347
|
+
.optional()
|
|
348
|
+
.describe(
|
|
349
|
+
'Search effort. fast is the balanced default, instant favors cached results and low latency, and deep broadens retrieval with reranking at higher cost and latency.',
|
|
350
|
+
),
|
|
351
|
+
sources: z
|
|
352
|
+
.object({
|
|
353
|
+
data: takoDataSourceInputSchema.optional(),
|
|
354
|
+
web: takoWebSourceInputSchema.optional(),
|
|
355
|
+
})
|
|
356
|
+
.optional()
|
|
357
|
+
.describe(
|
|
358
|
+
'Sources to search. Omit to search both curated data and the web. When provided, only keys present are searched.',
|
|
359
|
+
),
|
|
360
|
+
location: z
|
|
361
|
+
.object({
|
|
362
|
+
latitude: z.number().describe('Latitude between -90 and 90.'),
|
|
363
|
+
longitude: z.number().describe('Longitude between -180 and 180.'),
|
|
364
|
+
})
|
|
365
|
+
.optional()
|
|
366
|
+
.describe('End-user coordinates for localized results.'),
|
|
367
|
+
country_code: z
|
|
368
|
+
.string()
|
|
369
|
+
.optional()
|
|
370
|
+
.describe("Two-letter ISO 3166-1 country code, such as 'US'."),
|
|
371
|
+
locale: z.string().optional().describe("BCP-47 locale, such as 'en-US'."),
|
|
372
|
+
timezone: z
|
|
373
|
+
.string()
|
|
374
|
+
.optional()
|
|
375
|
+
.describe("IANA timezone, such as 'America/New_York'."),
|
|
376
|
+
output_settings: z
|
|
377
|
+
.object({
|
|
378
|
+
image_dark_mode: z
|
|
379
|
+
.boolean()
|
|
380
|
+
.optional()
|
|
381
|
+
.describe('Render card preview images in dark mode.'),
|
|
382
|
+
force_refresh: z
|
|
383
|
+
.boolean()
|
|
384
|
+
.optional()
|
|
385
|
+
.describe(
|
|
386
|
+
'Instant-effort only. Request a refreshed instant result.',
|
|
387
|
+
),
|
|
388
|
+
})
|
|
389
|
+
.optional()
|
|
390
|
+
.describe('Controls card rendering in the search response.'),
|
|
391
|
+
include_related: z
|
|
392
|
+
.number()
|
|
393
|
+
.optional()
|
|
394
|
+
.describe('Maximum related search suggestions to include (1-20).'),
|
|
395
|
+
}),
|
|
396
|
+
),
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
const takoDatasetCellSchema = z
|
|
400
|
+
.union([z.boolean(), z.number(), z.string()])
|
|
401
|
+
.nullable();
|
|
402
|
+
|
|
403
|
+
const takoResultContentSchema = z
|
|
404
|
+
.object({
|
|
405
|
+
content_format: z
|
|
406
|
+
.enum(['card_json', 'csv', 'json_compact', 'json_records'])
|
|
407
|
+
.nullish(),
|
|
408
|
+
cost: z.number().optional(),
|
|
409
|
+
data: z.string().nullish(),
|
|
410
|
+
records: z.array(z.record(z.string(), takoDatasetCellSchema)).nullish(),
|
|
411
|
+
dataset: z
|
|
412
|
+
.object({
|
|
413
|
+
columns: z.array(
|
|
414
|
+
z.object({
|
|
415
|
+
name: z.string(),
|
|
416
|
+
type: z.enum(['boolean', 'date', 'datetime', 'number', 'string']),
|
|
417
|
+
unit: z.string().nullish(),
|
|
418
|
+
}),
|
|
419
|
+
),
|
|
420
|
+
rows: z.array(z.array(takoDatasetCellSchema)),
|
|
421
|
+
total_rows: z.number(),
|
|
422
|
+
truncated: z.boolean(),
|
|
423
|
+
ref: z.string(),
|
|
424
|
+
sources: z.array(
|
|
425
|
+
z.object({
|
|
426
|
+
name: z.string(),
|
|
427
|
+
index: z.enum(['data', 'web']).optional(),
|
|
428
|
+
}),
|
|
429
|
+
),
|
|
430
|
+
provenance: z.enum(['query', 'web_extraction']).optional(),
|
|
431
|
+
})
|
|
432
|
+
.nullish(),
|
|
433
|
+
card_data: z.object({}).passthrough().nullish(),
|
|
434
|
+
card_data_schema: z.object({}).passthrough().nullish(),
|
|
435
|
+
url: z.string().nullish(),
|
|
436
|
+
expires_at: z.string().nullish(),
|
|
437
|
+
total_rows: z.number().nullish(),
|
|
438
|
+
truncated: z.boolean().optional(),
|
|
439
|
+
export_pricing: z
|
|
440
|
+
.object({
|
|
441
|
+
baseline_usd: z.number(),
|
|
442
|
+
free_rows: z.number(),
|
|
443
|
+
max_rows_ceiling: z.number(),
|
|
444
|
+
row_cpm_usd: z.number(),
|
|
445
|
+
})
|
|
446
|
+
.nullish(),
|
|
447
|
+
manifest: z
|
|
448
|
+
.array(
|
|
449
|
+
z.object({
|
|
450
|
+
dtype: z
|
|
451
|
+
.enum(['boolean', 'date', 'datetime', 'number', 'string'])
|
|
452
|
+
.nullish(),
|
|
453
|
+
entity: z.string().nullish(),
|
|
454
|
+
metric: z.string().nullish(),
|
|
455
|
+
name: z.string().nullish(),
|
|
456
|
+
unit: z.string().nullish(),
|
|
457
|
+
}),
|
|
458
|
+
)
|
|
459
|
+
.nullish(),
|
|
460
|
+
})
|
|
461
|
+
.passthrough();
|
|
462
|
+
|
|
463
|
+
const takoCardSchema = z
|
|
464
|
+
.object({
|
|
465
|
+
card_id: z.string().nullish(),
|
|
466
|
+
title: z.string().nullish(),
|
|
467
|
+
description: z.string().nullish(),
|
|
468
|
+
semantic_description: z.string().nullish(),
|
|
469
|
+
webpage_url: z.string().nullish(),
|
|
470
|
+
image_url: z.string().nullish(),
|
|
471
|
+
embed_url: z.string().nullish(),
|
|
472
|
+
sources: z
|
|
473
|
+
.array(
|
|
474
|
+
z.object({
|
|
475
|
+
source_name: z.string().nullish(),
|
|
476
|
+
source_description: z.string().nullish(),
|
|
477
|
+
source_index: z.enum(['data', 'web']),
|
|
478
|
+
source_text: z.string().nullish(),
|
|
479
|
+
url: z.string().nullish(),
|
|
480
|
+
}),
|
|
481
|
+
)
|
|
482
|
+
.nullish(),
|
|
483
|
+
methodologies: z
|
|
484
|
+
.array(
|
|
485
|
+
z.object({
|
|
486
|
+
methodology_name: z.string().nullable(),
|
|
487
|
+
methodology_description: z.string().nullable(),
|
|
488
|
+
}),
|
|
489
|
+
)
|
|
490
|
+
.nullish(),
|
|
491
|
+
source_indexes: z.array(z.enum(['data', 'web'])).nullish(),
|
|
492
|
+
card_type: z.string().nullish(),
|
|
493
|
+
relevance: z.enum(['High', 'Low', 'Medium']).nullish(),
|
|
494
|
+
content: takoResultContentSchema.nullish(),
|
|
495
|
+
exportable: z.boolean().optional(),
|
|
496
|
+
relevance_score: z.number().nullish(),
|
|
497
|
+
nodes: z
|
|
498
|
+
.array(
|
|
499
|
+
z.object({
|
|
500
|
+
id: z.string(),
|
|
501
|
+
type: z.enum(['entity', 'metric']),
|
|
502
|
+
name: z.string(),
|
|
503
|
+
description: z.string().nullish(),
|
|
504
|
+
}),
|
|
505
|
+
)
|
|
506
|
+
.nullish(),
|
|
507
|
+
metric_definitions: z
|
|
508
|
+
.array(z.object({ name: z.string(), definition: z.string() }))
|
|
509
|
+
.nullish(),
|
|
510
|
+
data_freshness: z
|
|
511
|
+
.object({
|
|
512
|
+
coverage_end: z.string().nullish(),
|
|
513
|
+
data_as_of: z.string().nullish(),
|
|
514
|
+
last_updated: z.string().nullish(),
|
|
515
|
+
})
|
|
516
|
+
.nullish(),
|
|
517
|
+
})
|
|
518
|
+
.passthrough();
|
|
519
|
+
|
|
520
|
+
const takoWebResultSchema = z
|
|
521
|
+
.object({
|
|
522
|
+
title: z.string(),
|
|
523
|
+
url: z.string(),
|
|
524
|
+
snippet: z.string().nullish(),
|
|
525
|
+
source_name: z.string().nullish(),
|
|
526
|
+
publish_date: z.string().nullish(),
|
|
527
|
+
content: takoResultContentSchema.nullish(),
|
|
528
|
+
citation_number: z.number().nullish(),
|
|
529
|
+
})
|
|
530
|
+
.passthrough();
|
|
531
|
+
|
|
532
|
+
const takoSearchOutputSchema = lazySchema(() =>
|
|
533
|
+
zodSchema(
|
|
534
|
+
z.union([
|
|
535
|
+
z
|
|
536
|
+
.object({
|
|
537
|
+
request_id: z.string(),
|
|
538
|
+
cards: z.array(takoCardSchema).optional(),
|
|
539
|
+
web_results: z.array(takoWebResultSchema).optional(),
|
|
540
|
+
usage: z
|
|
541
|
+
.object({
|
|
542
|
+
total_cost_usd: z.number(),
|
|
543
|
+
compute: z.object({ cost_usd: z.number() }).nullish(),
|
|
544
|
+
data: z
|
|
545
|
+
.object({ cost_usd: z.number(), datasets: z.number() })
|
|
546
|
+
.nullish(),
|
|
547
|
+
})
|
|
548
|
+
.nullish(),
|
|
549
|
+
related: z.array(z.object({}).passthrough()).nullish(),
|
|
550
|
+
})
|
|
551
|
+
.passthrough(),
|
|
552
|
+
z.object({
|
|
553
|
+
error: z.enum([
|
|
554
|
+
'api_error',
|
|
555
|
+
'configuration_error',
|
|
556
|
+
'execution_error',
|
|
557
|
+
'invalid_input',
|
|
558
|
+
'rate_limit',
|
|
559
|
+
'timeout',
|
|
560
|
+
'unknown_tool',
|
|
561
|
+
]),
|
|
562
|
+
statusCode: z.number().optional(),
|
|
563
|
+
message: z.string(),
|
|
564
|
+
}),
|
|
565
|
+
]),
|
|
566
|
+
),
|
|
567
|
+
);
|
|
568
|
+
|
|
569
|
+
export const takoSearchToolFactory = createProviderExecutedToolFactory<
|
|
570
|
+
TakoSearchInput,
|
|
571
|
+
TakoSearchOutput,
|
|
572
|
+
TakoSearchConfig
|
|
573
|
+
>({
|
|
574
|
+
id: 'gateway.tako_search',
|
|
575
|
+
inputSchema: takoSearchInputSchema,
|
|
576
|
+
outputSchema: takoSearchOutputSchema,
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
export const takoSearch = (
|
|
580
|
+
config: TakoSearchConfig = {},
|
|
581
|
+
): ReturnType<typeof takoSearchToolFactory> => takoSearchToolFactory(config);
|