Skip to content

Commit e30d513

Browse files
committed
improvement(tavily): mark optional params advanced; fix empty content output
- Mark 29 optional search/extract/crawl/map subBlocks as mode: advanced (keep query/urls/url/apiKey basic) - Fix search transformResponse: populate content from result.content (was result.snippet, always empty) - Guard data.results with ?? []; correct country placeholder to a lowercase name - Rewrite stale TavilySearch/Extract response interfaces; drop dead duplicate interfaces
1 parent 355bde5 commit e30d513

3 files changed

Lines changed: 62 additions & 63 deletions

File tree

apps/sim/blocks/blocks/tavily.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const TavilyBlock: BlockConfig<TavilyResponse> = {
4141
title: 'Max Results',
4242
type: 'short-input',
4343
placeholder: '5',
44+
mode: 'advanced',
4445
condition: { field: 'operation', value: 'tavily_search' },
4546
},
4647
{
@@ -53,6 +54,7 @@ export const TavilyBlock: BlockConfig<TavilyResponse> = {
5354
{ label: 'Finance', id: 'finance' },
5455
],
5556
value: () => 'general',
57+
mode: 'advanced',
5658
condition: { field: 'operation', value: 'tavily_search' },
5759
},
5860
{
@@ -64,6 +66,7 @@ export const TavilyBlock: BlockConfig<TavilyResponse> = {
6466
{ label: 'Advanced', id: 'advanced' },
6567
],
6668
value: () => 'basic',
69+
mode: 'advanced',
6770
condition: { field: 'operation', value: 'tavily_search' },
6871
},
6972
{
@@ -76,6 +79,7 @@ export const TavilyBlock: BlockConfig<TavilyResponse> = {
7679
{ label: 'Advanced', id: 'advanced' },
7780
],
7881
value: () => '',
82+
mode: 'advanced',
7983
condition: { field: 'operation', value: 'tavily_search' },
8084
},
8185
{
@@ -88,24 +92,28 @@ export const TavilyBlock: BlockConfig<TavilyResponse> = {
8892
{ label: 'Text', id: 'text' },
8993
],
9094
value: () => '',
95+
mode: 'advanced',
9196
condition: { field: 'operation', value: 'tavily_search' },
9297
},
9398
{
9499
id: 'include_images',
95100
title: 'Include Images',
96101
type: 'switch',
102+
mode: 'advanced',
97103
condition: { field: 'operation', value: 'tavily_search' },
98104
},
99105
{
100106
id: 'include_image_descriptions',
101107
title: 'Include Image Descriptions',
102108
type: 'switch',
109+
mode: 'advanced',
103110
condition: { field: 'operation', value: 'tavily_search' },
104111
},
105112
{
106113
id: 'include_favicon',
107114
title: 'Include Favicon',
108115
type: 'switch',
116+
mode: 'advanced',
109117
condition: { field: 'operation', value: 'tavily_search' },
110118
},
111119
{
@@ -120,27 +128,31 @@ export const TavilyBlock: BlockConfig<TavilyResponse> = {
120128
{ label: 'Year', id: 'y' },
121129
],
122130
value: () => '',
131+
mode: 'advanced',
123132
condition: { field: 'operation', value: 'tavily_search' },
124133
},
125134
{
126135
id: 'include_domains',
127136
title: 'Include Domains',
128137
type: 'long-input',
129138
placeholder: 'example.com, another.com (comma-separated)',
139+
mode: 'advanced',
130140
condition: { field: 'operation', value: 'tavily_search' },
131141
},
132142
{
133143
id: 'exclude_domains',
134144
title: 'Exclude Domains',
135145
type: 'long-input',
136146
placeholder: 'example.com, another.com (comma-separated)',
147+
mode: 'advanced',
137148
condition: { field: 'operation', value: 'tavily_search' },
138149
},
139150
{
140151
id: 'country',
141152
title: 'Country',
142153
type: 'short-input',
143-
placeholder: 'US',
154+
placeholder: 'united states',
155+
mode: 'advanced',
144156
condition: { field: 'operation', value: 'tavily_search' },
145157
},
146158
{
@@ -160,6 +172,7 @@ export const TavilyBlock: BlockConfig<TavilyResponse> = {
160172
{ label: 'Advanced', id: 'advanced' },
161173
],
162174
value: () => 'basic',
175+
mode: 'advanced',
163176
condition: { field: 'operation', value: 'tavily_extract' },
164177
},
165178
{
@@ -171,18 +184,21 @@ export const TavilyBlock: BlockConfig<TavilyResponse> = {
171184
{ label: 'Text', id: 'text' },
172185
],
173186
value: () => 'markdown',
187+
mode: 'advanced',
174188
condition: { field: 'operation', value: 'tavily_extract' },
175189
},
176190
{
177191
id: 'include_images',
178192
title: 'Include Images',
179193
type: 'switch',
194+
mode: 'advanced',
180195
condition: { field: 'operation', value: 'tavily_extract' },
181196
},
182197
{
183198
id: 'include_favicon',
184199
title: 'Include Favicon',
185200
type: 'switch',
201+
mode: 'advanced',
186202
condition: { field: 'operation', value: 'tavily_extract' },
187203
},
188204
{
@@ -198,67 +214,77 @@ export const TavilyBlock: BlockConfig<TavilyResponse> = {
198214
title: 'Instructions',
199215
type: 'long-input',
200216
placeholder: 'Natural language directions for the crawler...',
217+
mode: 'advanced',
201218
condition: { field: 'operation', value: ['tavily_crawl', 'tavily_map'] },
202219
},
203220
{
204221
id: 'max_depth',
205222
title: 'Max Depth',
206223
type: 'short-input',
207224
placeholder: '1',
225+
mode: 'advanced',
208226
condition: { field: 'operation', value: ['tavily_crawl', 'tavily_map'] },
209227
},
210228
{
211229
id: 'max_breadth',
212230
title: 'Max Breadth',
213231
type: 'short-input',
214232
placeholder: '20',
233+
mode: 'advanced',
215234
condition: { field: 'operation', value: ['tavily_crawl', 'tavily_map'] },
216235
},
217236
{
218237
id: 'limit',
219238
title: 'Limit',
220239
type: 'short-input',
221240
placeholder: '50',
241+
mode: 'advanced',
222242
condition: { field: 'operation', value: ['tavily_crawl', 'tavily_map'] },
223243
},
224244
{
225245
id: 'select_paths',
226246
title: 'Select Paths',
227247
type: 'long-input',
228248
placeholder: '/docs/.*, /api/.* (regex patterns, comma-separated)',
249+
mode: 'advanced',
229250
condition: { field: 'operation', value: ['tavily_crawl', 'tavily_map'] },
230251
},
231252
{
232253
id: 'select_domains',
233254
title: 'Select Domains',
234255
type: 'long-input',
235256
placeholder: '^docs\\.example\\.com$ (regex patterns, comma-separated)',
257+
mode: 'advanced',
236258
condition: { field: 'operation', value: ['tavily_crawl', 'tavily_map'] },
237259
},
238260
{
239261
id: 'exclude_paths',
240262
title: 'Exclude Paths',
241263
type: 'long-input',
242264
placeholder: '/private/.*, /admin/.* (regex patterns, comma-separated)',
265+
mode: 'advanced',
243266
condition: { field: 'operation', value: ['tavily_crawl', 'tavily_map'] },
244267
},
245268
{
246269
id: 'exclude_domains',
247270
title: 'Exclude Domains',
248271
type: 'long-input',
249272
placeholder: '^private\\.example\\.com$ (regex patterns, comma-separated)',
273+
mode: 'advanced',
250274
condition: { field: 'operation', value: ['tavily_crawl', 'tavily_map'] },
251275
},
252276
{
253277
id: 'allow_external',
254278
title: 'Allow External Links',
255279
type: 'switch',
280+
mode: 'advanced',
256281
condition: { field: 'operation', value: ['tavily_crawl', 'tavily_map'] },
257282
},
258283
{
259284
id: 'include_images',
260285
title: 'Include Images',
261286
type: 'switch',
287+
mode: 'advanced',
262288
condition: { field: 'operation', value: 'tavily_crawl' },
263289
},
264290
{
@@ -270,6 +296,7 @@ export const TavilyBlock: BlockConfig<TavilyResponse> = {
270296
{ label: 'Advanced', id: 'advanced' },
271297
],
272298
value: () => 'basic',
299+
mode: 'advanced',
273300
condition: { field: 'operation', value: 'tavily_crawl' },
274301
},
275302
{
@@ -281,12 +308,14 @@ export const TavilyBlock: BlockConfig<TavilyResponse> = {
281308
{ label: 'Text', id: 'text' },
282309
],
283310
value: () => 'markdown',
311+
mode: 'advanced',
284312
condition: { field: 'operation', value: 'tavily_crawl' },
285313
},
286314
{
287315
id: 'include_favicon',
288316
title: 'Include Favicon',
289317
type: 'switch',
318+
mode: 'advanced',
290319
condition: { field: 'operation', value: 'tavily_crawl' },
291320
},
292321
{

apps/sim/tools/tavily/search.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ export const searchTool: ToolConfig<TavilySearchParams, TavilySearchResponse> =
192192
success: true,
193193
output: {
194194
query: data.query,
195-
results: data.results.map((result: any) => ({
195+
results: (data.results ?? []).map((result: any) => ({
196196
title: result.title,
197197
url: result.url,
198-
snippet: result.snippet,
198+
content: result.content,
199199
...(result.score !== undefined && { score: result.score }),
200200
...(result.raw_content && { raw_content: result.raw_content }),
201201
...(result.favicon && { favicon: result.favicon }),

apps/sim/tools/tavily/types.ts

Lines changed: 30 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -142,27 +142,42 @@ interface TavilySearchResult {
142142
title: string
143143
url: string
144144
content: string
145-
score: number
146-
images?: string[]
145+
score?: number
147146
raw_content?: string
147+
favicon?: string
148+
}
149+
150+
interface TavilyImageResult {
151+
url: string
152+
description?: string
148153
}
149154

150155
export interface TavilySearchResponse extends ToolResponse {
151156
output: {
157+
query: string
152158
results: TavilySearchResult[]
153159
answer?: string
154-
query: string
155-
images?: string[]
156-
rawContent?: string
160+
images?: Array<string | TavilyImageResult>
161+
auto_parameters?: Record<string, unknown>
162+
response_time: number
157163
}
158164
}
159165

166+
interface TavilyExtractResultItem {
167+
url: string
168+
raw_content: string
169+
images?: string[]
170+
favicon?: string
171+
}
172+
160173
export interface TavilyExtractResponse extends ToolResponse {
161174
output: {
162-
content: string
163-
title: string
164-
url: string
165-
rawContent?: string
175+
results: TavilyExtractResultItem[]
176+
failed_results?: Array<{
177+
url: string
178+
error: string
179+
}>
180+
response_time: number
166181
}
167182
}
168183

@@ -175,22 +190,6 @@ export interface TavilyExtractParams {
175190
include_favicon?: boolean
176191
}
177192

178-
interface ExtractResult {
179-
url: string
180-
raw_content: string
181-
}
182-
183-
interface ExtractResponse extends ToolResponse {
184-
output: {
185-
results: ExtractResult[]
186-
failed_results?: Array<{
187-
url: string
188-
error: string
189-
}>
190-
response_time: number
191-
}
192-
}
193-
194193
export interface TavilySearchParams {
195194
query: string
196195
apiKey: string
@@ -212,24 +211,11 @@ export interface TavilySearchParams {
212211
auto_parameters?: boolean
213212
}
214213

215-
interface SearchResult {
216-
title: string
217-
url: string
218-
snippet: string
219-
raw_content?: string
220-
}
221-
222-
interface SearchResponse extends ToolResponse {
223-
output: {
224-
query: string
225-
results: SearchResult[]
226-
response_time: number
227-
}
228-
}
229-
230214
export type TavilyResponse = TavilySearchResponse | TavilyExtractResponse
231215

232-
// Crawl API types
216+
/**
217+
* Parameters for the Tavily Crawl tool.
218+
*/
233219
export interface TavilyCrawlParams {
234220
url: string
235221
apiKey: string
@@ -263,16 +249,9 @@ export interface CrawlResponse extends ToolResponse {
263249
}
264250
}
265251

266-
interface TavilyCrawlResponse extends ToolResponse {
267-
output: {
268-
base_url: string
269-
results: CrawlResult[]
270-
response_time: number
271-
request_id?: string
272-
}
273-
}
274-
275-
// Map API types
252+
/**
253+
* Parameters for the Tavily Map tool.
254+
*/
276255
export interface TavilyMapParams {
277256
url: string
278257
apiKey: string
@@ -299,12 +278,3 @@ export interface MapResponse extends ToolResponse {
299278
request_id?: string
300279
}
301280
}
302-
303-
interface TavilyMapResponse extends ToolResponse {
304-
output: {
305-
base_url: string
306-
results: MapResult[]
307-
response_time: number
308-
request_id?: string
309-
}
310-
}

0 commit comments

Comments
 (0)