-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Expand file tree
/
Copy pathexa.ts
More file actions
396 lines (395 loc) · 12.2 KB
/
exa.ts
File metadata and controls
396 lines (395 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
import { ExaAIIcon } from '@/components/icons'
import type { BlockConfig } from '@/blocks/types'
import { AuthMode } from '@/blocks/types'
import type { ExaResponse } from '@/tools/exa/types'
export const ExaBlock: BlockConfig<ExaResponse> = {
type: 'exa',
name: 'Exa',
description: 'Search with Exa AI',
authMode: AuthMode.ApiKey,
longDescription:
'Integrate Exa into the workflow. Can search, get contents, find similar links, answer a question, and perform research.',
docsLink: 'https://docs.sim.ai/tools/exa',
category: 'tools',
bgColor: '#1F40ED',
icon: ExaAIIcon,
subBlocks: [
{
id: 'operation',
title: 'Operation',
type: 'dropdown',
options: [
{ label: 'Search', id: 'exa_search' },
{ label: 'Get Contents', id: 'exa_get_contents' },
{ label: 'Find Similar Links', id: 'exa_find_similar_links' },
{ label: 'Answer', id: 'exa_answer' },
{ label: 'Research', id: 'exa_research' },
],
value: () => 'exa_search',
},
// Search operation inputs
{
id: 'query',
title: 'Search Query',
type: 'long-input',
placeholder: 'Enter your search query...',
condition: { field: 'operation', value: 'exa_search' },
required: true,
},
{
id: 'numResults',
title: 'Number of Results',
type: 'short-input',
placeholder: '10',
condition: { field: 'operation', value: 'exa_search' },
},
{
id: 'useAutoprompt',
title: 'Use Autoprompt',
type: 'switch',
condition: { field: 'operation', value: 'exa_search' },
mode: 'advanced',
},
{
id: 'type',
title: 'Search Type',
type: 'dropdown',
options: [
{ label: 'Auto', id: 'auto' },
{ label: 'Neural', id: 'neural' },
{ label: 'Keyword', id: 'keyword' },
{ label: 'Fast', id: 'fast' },
],
value: () => 'auto',
condition: { field: 'operation', value: 'exa_search' },
mode: 'advanced',
},
{
id: 'includeDomains',
title: 'Include Domains',
type: 'long-input',
placeholder: 'example.com, another.com (comma-separated)',
condition: { field: 'operation', value: 'exa_search' },
mode: 'advanced',
},
{
id: 'excludeDomains',
title: 'Exclude Domains',
type: 'long-input',
placeholder: 'exclude.com, another.com (comma-separated)',
condition: { field: 'operation', value: 'exa_search' },
mode: 'advanced',
},
{
id: 'category',
title: 'Category Filter',
type: 'dropdown',
options: [
{ label: 'None', id: '' },
{ label: 'Company', id: 'company' },
{ label: 'Research Paper', id: 'research_paper' },
{ label: 'News Article', id: 'news_article' },
{ label: 'PDF', id: 'pdf' },
{ label: 'GitHub', id: 'github' },
{ label: 'Tweet', id: 'tweet' },
{ label: 'Movie', id: 'movie' },
{ label: 'Song', id: 'song' },
{ label: 'Personal Site', id: 'personal_site' },
],
value: () => '',
condition: { field: 'operation', value: 'exa_search' },
mode: 'advanced',
},
{
id: 'text',
title: 'Include Text',
type: 'switch',
condition: { field: 'operation', value: 'exa_search' },
},
{
id: 'highlights',
title: 'Include Highlights',
type: 'switch',
condition: { field: 'operation', value: 'exa_search' },
mode: 'advanced',
},
{
id: 'summary',
title: 'Include Summary',
type: 'switch',
condition: { field: 'operation', value: 'exa_search' },
mode: 'advanced',
},
{
id: 'livecrawl',
title: 'Live Crawl Mode',
type: 'dropdown',
options: [
{ label: 'Never (default)', id: 'never' },
{ label: 'Fallback', id: 'fallback' },
{ label: 'Always', id: 'always' },
],
value: () => 'never',
condition: { field: 'operation', value: 'exa_search' },
mode: 'advanced',
},
// Get Contents operation inputs
{
id: 'urls',
title: 'URLs',
type: 'long-input',
placeholder: 'Enter URLs to retrieve content from (comma-separated)...',
condition: { field: 'operation', value: 'exa_get_contents' },
required: true,
},
{
id: 'text',
title: 'Include Text',
type: 'switch',
condition: { field: 'operation', value: 'exa_get_contents' },
},
{
id: 'summaryQuery',
title: 'Summary Query',
type: 'long-input',
placeholder: 'Enter a query to guide the summary generation...',
condition: { field: 'operation', value: 'exa_get_contents' },
mode: 'advanced',
},
{
id: 'subpages',
title: 'Number of Subpages',
type: 'short-input',
placeholder: '5',
condition: { field: 'operation', value: 'exa_get_contents' },
mode: 'advanced',
},
{
id: 'subpageTarget',
title: 'Subpage Target Keywords',
type: 'long-input',
placeholder: 'docs, tutorial, about (comma-separated)',
condition: { field: 'operation', value: 'exa_get_contents' },
mode: 'advanced',
},
{
id: 'highlights',
title: 'Include Highlights',
type: 'switch',
condition: { field: 'operation', value: 'exa_get_contents' },
mode: 'advanced',
},
// Find Similar Links operation inputs
{
id: 'url',
title: 'URL',
type: 'long-input',
placeholder: 'Enter URL to find similar links for...',
condition: { field: 'operation', value: 'exa_find_similar_links' },
required: true,
},
{
id: 'numResults',
title: 'Number of Results',
type: 'short-input',
placeholder: '10',
condition: { field: 'operation', value: 'exa_find_similar_links' },
},
{
id: 'text',
title: 'Include Text',
type: 'switch',
condition: { field: 'operation', value: 'exa_find_similar_links' },
},
{
id: 'includeDomains',
title: 'Include Domains',
type: 'long-input',
placeholder: 'example.com, another.com (comma-separated)',
condition: { field: 'operation', value: 'exa_find_similar_links' },
mode: 'advanced',
},
{
id: 'excludeDomains',
title: 'Exclude Domains',
type: 'long-input',
placeholder: 'exclude.com, another.com (comma-separated)',
condition: { field: 'operation', value: 'exa_find_similar_links' },
mode: 'advanced',
},
{
id: 'excludeSourceDomain',
title: 'Exclude Source Domain',
type: 'switch',
condition: { field: 'operation', value: 'exa_find_similar_links' },
mode: 'advanced',
},
{
id: 'category',
title: 'Category Filter',
type: 'dropdown',
options: [
{ label: 'None', id: '' },
{ label: 'Company', id: 'company' },
{ label: 'Research Paper', id: 'research_paper' },
{ label: 'News Article', id: 'news_article' },
{ label: 'PDF', id: 'pdf' },
{ label: 'GitHub', id: 'github' },
{ label: 'Tweet', id: 'tweet' },
{ label: 'Movie', id: 'movie' },
{ label: 'Song', id: 'song' },
{ label: 'Personal Site', id: 'personal_site' },
],
value: () => '',
condition: { field: 'operation', value: 'exa_find_similar_links' },
mode: 'advanced',
},
{
id: 'highlights',
title: 'Include Highlights',
type: 'switch',
condition: { field: 'operation', value: 'exa_find_similar_links' },
mode: 'advanced',
},
{
id: 'summary',
title: 'Include Summary',
type: 'switch',
condition: { field: 'operation', value: 'exa_find_similar_links' },
mode: 'advanced',
},
{
id: 'livecrawl',
title: 'Live Crawl Mode',
type: 'dropdown',
options: [
{ label: 'Never (default)', id: 'never' },
{ label: 'Fallback', id: 'fallback' },
{ label: 'Always', id: 'always' },
],
value: () => 'never',
condition: { field: 'operation', value: 'exa_find_similar_links' },
mode: 'advanced',
},
// Answer operation inputs
{
id: 'query',
title: 'Question',
type: 'long-input',
placeholder: 'Enter your question...',
condition: { field: 'operation', value: 'exa_answer' },
required: true,
},
{
id: 'text',
title: 'Include Text',
type: 'switch',
condition: { field: 'operation', value: 'exa_answer' },
mode: 'advanced',
},
// Research operation inputs
{
id: 'query',
title: 'Research Query',
type: 'long-input',
placeholder: 'Enter your research topic or question...',
condition: { field: 'operation', value: 'exa_research' },
required: true,
},
{
id: 'model',
title: 'Research Model',
type: 'dropdown',
options: [
{ label: 'Standard (default)', id: 'exa-research' },
{ label: 'Fast', id: 'exa-research-fast' },
{ label: 'Pro', id: 'exa-research-pro' },
],
value: () => 'exa-research',
condition: { field: 'operation', value: 'exa_research' },
},
// API Key (common)
{
id: 'apiKey',
title: 'API Key',
type: 'short-input',
placeholder: 'Enter your Exa API key',
password: true,
required: true,
},
],
tools: {
access: [
'exa_search',
'exa_get_contents',
'exa_find_similar_links',
'exa_answer',
'exa_research',
],
config: {
tool: (params) => {
switch (params.operation) {
case 'exa_search':
return 'exa_search'
case 'exa_get_contents':
return 'exa_get_contents'
case 'exa_find_similar_links':
return 'exa_find_similar_links'
case 'exa_answer':
return 'exa_answer'
case 'exa_research':
return 'exa_research'
default:
return 'exa_search'
}
},
params: (params) => {
const result: Record<string, unknown> = {}
if (params.numResults) {
result.numResults = Number(params.numResults)
}
if (params.subpages) {
result.subpages = Number(params.subpages)
}
return result
},
},
},
inputs: {
operation: { type: 'string', description: 'Operation to perform' },
apiKey: { type: 'string', description: 'Exa API key' },
// Search operation
query: { type: 'string', description: 'Search query terms' },
numResults: { type: 'number', description: 'Number of results' },
useAutoprompt: { type: 'boolean', description: 'Use autoprompt feature' },
type: { type: 'string', description: 'Search type' },
includeDomains: { type: 'string', description: 'Include domains filter' },
excludeDomains: { type: 'string', description: 'Exclude domains filter' },
category: { type: 'string', description: 'Category filter' },
text: { type: 'boolean', description: 'Include text content' },
highlights: { type: 'boolean', description: 'Include highlights' },
summary: { type: 'boolean', description: 'Include summary' },
livecrawl: { type: 'string', description: 'Live crawl mode' },
// Get Contents operation
urls: { type: 'string', description: 'URLs to retrieve' },
summaryQuery: { type: 'string', description: 'Summary query guidance' },
subpages: { type: 'number', description: 'Number of subpages to crawl' },
subpageTarget: { type: 'string', description: 'Subpage target keywords' },
// Find Similar Links operation
url: { type: 'string', description: 'Source URL' },
excludeSourceDomain: { type: 'boolean', description: 'Exclude source domain' },
// Research operation
model: { type: 'string', description: 'Research model selection' },
},
outputs: {
// Search output
results: { type: 'json', description: 'Search results' },
// Find Similar Links output
similarLinks: { type: 'json', description: 'Similar links found' },
// Answer output
answer: { type: 'string', description: 'Generated answer' },
citations: { type: 'json', description: 'Answer citations' },
// Research output
research: { type: 'json', description: 'Research findings' },
},
}