-
-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Update Exa Search tool to current API #6407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
637f259
26fd05f
5b4f4d5
8dd980b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -50,41 +50,39 @@ class ExaSearch_Tools implements INode { | |||||||||
| type: 'options', | ||||||||||
| options: [ | ||||||||||
| { | ||||||||||
| label: 'keyword', | ||||||||||
| name: 'keyword' | ||||||||||
| label: 'auto', | ||||||||||
| name: 'auto' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'neural', | ||||||||||
| name: 'neural' | ||||||||||
| label: 'fast', | ||||||||||
| name: 'fast' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'auto', | ||||||||||
| name: 'auto', | ||||||||||
| description: 'decides between keyword and neural' | ||||||||||
| label: 'instant', | ||||||||||
| name: 'instant' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'deep', | ||||||||||
| name: 'deep' | ||||||||||
| } | ||||||||||
| ], | ||||||||||
| optional: true, | ||||||||||
| additionalParams: true | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'Use Auto Prompt', | ||||||||||
| name: 'useAutoprompt', | ||||||||||
| type: 'boolean', | ||||||||||
| optional: true, | ||||||||||
| additionalParams: true, | ||||||||||
| description: 'If true, your query will be converted to a Exa query. Default false.' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'Category (Beta)', | ||||||||||
| label: 'Category', | ||||||||||
| name: 'category', | ||||||||||
| type: 'options', | ||||||||||
| description: | ||||||||||
| 'A data category to focus on, with higher comprehensivity and data cleanliness. Categories right now include company, research paper, news, github, tweet, movie, song, personal site, and pdf', | ||||||||||
| description: 'A data category to focus on.', | ||||||||||
| options: [ | ||||||||||
| { | ||||||||||
| label: 'company', | ||||||||||
| name: 'company' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'people', | ||||||||||
| name: 'people' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'research paper', | ||||||||||
| name: 'research paper' | ||||||||||
|
|
@@ -93,34 +91,10 @@ class ExaSearch_Tools implements INode { | |||||||||
| label: 'news', | ||||||||||
| name: 'news' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'github', | ||||||||||
| name: 'github' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'tweet', | ||||||||||
| name: 'tweet' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'movie', | ||||||||||
| name: 'movie' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'song', | ||||||||||
| name: 'song' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'pdf', | ||||||||||
| name: 'pdf' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'personal site', | ||||||||||
| name: 'personal site' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'linkedin profile', | ||||||||||
| name: 'linkedin profile' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'financial report', | ||||||||||
| name: 'financial report' | ||||||||||
|
|
@@ -129,6 +103,15 @@ class ExaSearch_Tools implements INode { | |||||||||
| optional: true, | ||||||||||
| additionalParams: true | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'Max Age Hours', | ||||||||||
| name: 'maxAgeHours', | ||||||||||
| type: 'number', | ||||||||||
| optional: true, | ||||||||||
| additionalParams: true, | ||||||||||
| description: | ||||||||||
| 'Freshness control. 0 = always crawl, -1 = cache only, 24 = cache if less than 24h old.' | ||||||||||
| }, | ||||||||||
| { | ||||||||||
| label: 'Include Domains', | ||||||||||
| name: 'includeDomains', | ||||||||||
|
|
@@ -200,9 +183,9 @@ class ExaSearch_Tools implements INode { | |||||||||
| async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> { | ||||||||||
| const description = nodeData.inputs?.description as string | ||||||||||
| const numResults = nodeData.inputs?.numResults as string | ||||||||||
| const type = nodeData.inputs?.type as 'keyword' | 'neural' | 'auto' | undefined | ||||||||||
| const useAutoprompt = nodeData.inputs?.useAutoprompt as boolean | ||||||||||
| const type = nodeData.inputs?.type as string | undefined | ||||||||||
| const category = nodeData.inputs?.category as string | ||||||||||
| const maxAgeHours = nodeData.inputs?.maxAgeHours as string | ||||||||||
| const includeDomains = nodeData.inputs?.includeDomains as string | ||||||||||
| const excludeDomains = nodeData.inputs?.excludeDomains as string | ||||||||||
| const startCrawlDate = nodeData.inputs?.startCrawlDate as string | ||||||||||
|
|
@@ -213,19 +196,25 @@ class ExaSearch_Tools implements INode { | |||||||||
| const credentialData = await getCredentialData(nodeData.credential ?? '', options) | ||||||||||
| const exaSearchApiKey = getCredentialParam('exaSearchApiKey', credentialData, nodeData) | ||||||||||
|
|
||||||||||
| const client = new Exa(exaSearchApiKey) | ||||||||||
| ;(client as any).headers = { | ||||||||||
| ...(client as any).headers, | ||||||||||
| 'x-exa-integration': 'flowise-integration' | ||||||||||
| } | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The If the SDK version used does not support custom headers in the constructor or via a public property, this integration tracking might not be achievable through the SDK instance directly. You should verify if the header is actually being sent in your tests. |
||||||||||
|
|
||||||||||
| const tool = new ExaSearchResults({ | ||||||||||
| client: new Exa(exaSearchApiKey), | ||||||||||
| client, | ||||||||||
| searchArgs: { | ||||||||||
| numResults: numResults ? parseFloat(numResults) : undefined, | ||||||||||
| type: type || undefined, | ||||||||||
| useAutoprompt: useAutoprompt || undefined, | ||||||||||
| type: (type as any) || undefined, | ||||||||||
| category: (category as any) || undefined, | ||||||||||
| includeDomains: includeDomains ? includeDomains.split(',') : undefined, | ||||||||||
| excludeDomains: excludeDomains ? excludeDomains.split(',') : undefined, | ||||||||||
|
Comment on lines
204
to
205
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When splitting domains by comma, users might include spaces (e.g., "example.com, test.com"). It is recommended to trim each domain string to ensure the API receives clean values without leading or trailing whitespace. This approach of using simple, chained operations improves readability and reduces potential errors.
Suggested change
References
|
||||||||||
| startCrawlDate: startCrawlDate || undefined, | ||||||||||
| endCrawlDate: endCrawlDate || undefined, | ||||||||||
| startPublishedDate: startPublishedDate || undefined, | ||||||||||
| endPublishedDate: endPublishedDate || undefined | ||||||||||
| endPublishedDate: endPublishedDate || undefined, | ||||||||||
| ...(maxAgeHours ? { maxAgeHours: parseFloat(maxAgeHours) } : {}) | ||||||||||
| } | ||||||||||
| }) | ||||||||||
|
|
||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type for
typehas been generalized tostring | undefined, which reduces type safety. Since the supported search types are now a fixed set, it is better to use a union of the allowed string literals to maintain compile-time validation.