Update Exa Search tool to current API#6407
Conversation
…ation header - Search types: auto/fast/instant/deep (removed keyword/neural) - Categories: exactly 6 (company, people, research paper, news, personal site, financial report) - Removed useAutoprompt from UI - Added maxAgeHours for freshness control - Added x-exa-integration: flowise-integration header Co-Authored-By: Tanishq Jaiswal <tanishq.jaiswal97@gmail.com>
Co-Authored-By: Tanishq Jaiswal <tanishq.jaiswal97@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request updates the ExaSearch tool by adding new search types and a maxAgeHours parameter, while removing the useAutoprompt option and refining categories. Feedback indicates that the integration header implementation may be non-functional due to SDK limitations. Additionally, suggestions were made to improve type safety for search parameters and to trim whitespace when parsing domain lists.
| ;(client as any).headers = { | ||
| ...(client as any).headers, | ||
| 'x-exa-integration': 'flowise-integration' | ||
| } |
There was a problem hiding this comment.
The Exa client from the exa-js library does not typically expose or utilize a headers property on the instance for its requests. The internal request method in the SDK usually constructs headers dynamically using only the apiKey. Consequently, setting (client as any).headers is likely non-functional, and the x-exa-integration header will not be sent to the API.
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 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 |
There was a problem hiding this comment.
The type for type has been generalized to string | 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.
| const type = nodeData.inputs?.type as string | undefined | |
| const type = nodeData.inputs?.type as 'auto' | 'fast' | 'instant' | 'deep' | undefined |
| includeDomains: includeDomains ? includeDomains.split(',') : undefined, | ||
| excludeDomains: excludeDomains ? excludeDomains.split(',') : undefined, |
There was a problem hiding this comment.
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.
| includeDomains: includeDomains ? includeDomains.split(',') : undefined, | |
| excludeDomains: excludeDomains ? excludeDomains.split(',') : undefined, | |
| includeDomains: includeDomains ? includeDomains.split(',').map((d) => d.trim()) : undefined, | |
| excludeDomains: excludeDomains ? excludeDomains.split(',').map((d) => d.trim()) : undefined, |
References
- Prioritize code readability and understandability over conciseness. A series of simple, chained operations can be preferable to a single, more complex one if it improves understandability and reduces the potential for future errors.
Co-Authored-By: Tanishq Jaiswal <tanishq.jaiswal97@gmail.com>
Updates the Exa Search node to current API conventions:
auto,fast,instant,deep(removedkeyword/neural)maxAgeHoursparameteruseAutopromptfrom UIx-exa-integration: flowise-integrationheader