-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] Exa - new components #18878
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
Open
jcortes
wants to merge
1
commit into
master
Choose a base branch
from
exa-new-components
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
components/exa/actions/answer-question/answer-question.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import app from "../../exa.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "exa-answer-question", | ||
| name: "Answer Question", | ||
| description: "Generates LLM-powered responses to queries, informed by Exa search results with citations. Handles both factual queries requiring direct answers and open-ended questions needing detailed summaries. [See the documentation](https://docs.exa.ai/reference/answer)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| app, | ||
| query: { | ||
| label: "Question", | ||
| description: "The question or query to answer", | ||
| propDefinition: [ | ||
| app, | ||
| "query", | ||
| ], | ||
| }, | ||
| text: { | ||
| propDefinition: [ | ||
| app, | ||
| "text", | ||
| ], | ||
| description: "Whether to include full text content from search results in the response", | ||
| }, | ||
| stream: { | ||
| type: "boolean", | ||
| label: "Stream", | ||
| description: "Enable streaming response via server-sent events (not recommended for Pipedream workflows)", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| app, | ||
| query, | ||
| text, | ||
| stream, | ||
| } = this; | ||
|
|
||
| const response = await app.answer({ | ||
| $, | ||
| data: { | ||
| query, | ||
| text, | ||
| stream, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", "Successfully answered question."); | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return response; | ||
| }, | ||
| }; | ||
291 changes: 291 additions & 0 deletions
291
components/exa/actions/find-similar-links/find-similar-links.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,291 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import app from "../../exa.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "exa-find-similar-links", | ||
| name: "Find Similar Links", | ||
| description: "Identifies and retrieves web pages similar to a provided URL with optional content extraction. [See the documentation](https://docs.exa.ai/reference/find-similar-links)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| app, | ||
| url: { | ||
| propDefinition: [ | ||
| app, | ||
| "url", | ||
| ], | ||
| }, | ||
| numResults: { | ||
| propDefinition: [ | ||
| app, | ||
| "numResults", | ||
| ], | ||
| }, | ||
| includeDomains: { | ||
| propDefinition: [ | ||
| app, | ||
| "includeDomains", | ||
| ], | ||
| }, | ||
| excludeDomains: { | ||
| propDefinition: [ | ||
| app, | ||
| "excludeDomains", | ||
| ], | ||
| }, | ||
| startCrawlDate: { | ||
| propDefinition: [ | ||
| app, | ||
| "startCrawlDate", | ||
| ], | ||
| }, | ||
| endCrawlDate: { | ||
| propDefinition: [ | ||
| app, | ||
| "endCrawlDate", | ||
| ], | ||
| }, | ||
| startPublishedDate: { | ||
| propDefinition: [ | ||
| app, | ||
| "startPublishedDate", | ||
| ], | ||
| }, | ||
| endPublishedDate: { | ||
| propDefinition: [ | ||
| app, | ||
| "endPublishedDate", | ||
| ], | ||
| }, | ||
| includeText: { | ||
| propDefinition: [ | ||
| app, | ||
| "includeText", | ||
| ], | ||
| }, | ||
| excludeText: { | ||
| propDefinition: [ | ||
| app, | ||
| "excludeText", | ||
| ], | ||
| }, | ||
| context: { | ||
| propDefinition: [ | ||
| app, | ||
| "context", | ||
| ], | ||
| }, | ||
| moderation: { | ||
| propDefinition: [ | ||
| app, | ||
| "moderation", | ||
| ], | ||
| }, | ||
| contentsText: { | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| label: "Contents - Text", | ||
| propDefinition: [ | ||
| app, | ||
| "text", | ||
| ], | ||
| }, | ||
| contentsHighlightsNumSentences: { | ||
| label: "Contents - Highlights - Number of Sentences", | ||
| propDefinition: [ | ||
| app, | ||
| "highlightsNumSentences", | ||
| ], | ||
| }, | ||
| contentsHighlightsPerUrl: { | ||
| label: "Contents - Highlights - Number of Snippets per URL", | ||
| propDefinition: [ | ||
| app, | ||
| "highlightsPerUrl", | ||
| ], | ||
| }, | ||
| contentsHighlightsQuery: { | ||
| label: "Contents - Highlights - Custom Query", | ||
| propDefinition: [ | ||
| app, | ||
| "highlightsQuery", | ||
| ], | ||
| }, | ||
| contentsSummaryQuery: { | ||
| label: "Contents - Summary - Custom Query", | ||
| propDefinition: [ | ||
| app, | ||
| "summaryQuery", | ||
| ], | ||
| }, | ||
| contentsSummarySchema: { | ||
| label: "Contents - Summary - JSON Schema", | ||
| propDefinition: [ | ||
| app, | ||
| "summarySchema", | ||
| ], | ||
| }, | ||
| contentsLivecrawl: { | ||
| label: "Contents - Live Crawl", | ||
| propDefinition: [ | ||
| app, | ||
| "livecrawl", | ||
| ], | ||
| }, | ||
| contentsLivecrawlTimeout: { | ||
| label: "Contents - Live Crawl Timeout", | ||
| propDefinition: [ | ||
| app, | ||
| "livecrawlTimeout", | ||
| ], | ||
| }, | ||
| contentsSubpages: { | ||
| label: "Contents - Subpages", | ||
| propDefinition: [ | ||
| app, | ||
| "subpages", | ||
| ], | ||
| }, | ||
| contentsSubpageTarget: { | ||
| label: "Contents - Subpage Target", | ||
| propDefinition: [ | ||
| app, | ||
| "subpageTarget", | ||
| ], | ||
| }, | ||
| contentsExtrasLinks: { | ||
| label: "Contents - Extras - Number of Links", | ||
| propDefinition: [ | ||
| app, | ||
| "extrasLinks", | ||
| ], | ||
| }, | ||
| contentsExtrasImageLinks: { | ||
| label: "Contents - Extras - Number of Image Links", | ||
| propDefinition: [ | ||
| app, | ||
| "extrasImageLinks", | ||
| ], | ||
| }, | ||
| contentsContext: { | ||
| label: "Contents - Context", | ||
| propDefinition: [ | ||
| app, | ||
| "context", | ||
| ], | ||
| }, | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async run({ $ }) { | ||
| const { | ||
| app, | ||
| url, | ||
| numResults, | ||
| includeDomains, | ||
| excludeDomains, | ||
| startCrawlDate, | ||
| endCrawlDate, | ||
| startPublishedDate, | ||
| endPublishedDate, | ||
| includeText, | ||
| excludeText, | ||
| contentsText, | ||
| contentsHighlightsNumSentences, | ||
| contentsHighlightsPerUrl, | ||
| contentsHighlightsQuery, | ||
| contentsSummaryQuery, | ||
| contentsSummarySchema, | ||
| contentsLivecrawl, | ||
| contentsLivecrawlTimeout, | ||
| contentsSubpages, | ||
| contentsSubpageTarget, | ||
| contentsExtrasLinks, | ||
| contentsExtrasImageLinks, | ||
| contentsContext, | ||
| } = this; | ||
|
|
||
| const highlights = contentsHighlightsNumSentences | ||
| || contentsHighlightsPerUrl | ||
| || contentsHighlightsQuery | ||
| ? { | ||
| numSentences: contentsHighlightsNumSentences, | ||
| highlightsPerUrl: contentsHighlightsPerUrl, | ||
| query: contentsHighlightsQuery, | ||
| } | ||
| : undefined; | ||
|
|
||
| let parsedSchema; | ||
| if (contentsSummarySchema) { | ||
| if (typeof contentsSummarySchema === "string") { | ||
| try { | ||
| parsedSchema = JSON.parse(contentsSummarySchema); | ||
| } catch (error) { | ||
| throw new ConfigurationError(`Invalid JSON schema format: ${error.message}. Please provide a valid JSON object.`); | ||
| } | ||
| } else { | ||
| parsedSchema = contentsSummarySchema; | ||
| } | ||
| } | ||
|
|
||
| const summary = contentsSummaryQuery | ||
| || contentsSummarySchema | ||
| ? { | ||
| query: contentsSummaryQuery, | ||
| schema: parsedSchema, | ||
| } | ||
| : undefined; | ||
|
|
||
| const extras = contentsExtrasLinks | ||
| || contentsExtrasImageLinks | ||
| ? { | ||
| links: contentsExtrasLinks, | ||
| imageLinks: contentsExtrasImageLinks, | ||
| } | ||
| : undefined; | ||
|
|
||
| const response = await app.findSimilar({ | ||
| $, | ||
| data: { | ||
| url, | ||
| numResults, | ||
| includeDomains, | ||
| excludeDomains, | ||
| startCrawlDate, | ||
| endCrawlDate, | ||
| startPublishedDate, | ||
| endPublishedDate, | ||
| includeText, | ||
| excludeText, | ||
| ...(contentsText | ||
| || contentsLivecrawl | ||
| || contentsLivecrawlTimeout | ||
| || contentsSubpages | ||
| || contentsSubpageTarget | ||
| || contentsContext | ||
| || highlights | ||
| || summary | ||
| || extras | ||
| ? { | ||
| contents: { | ||
| text: contentsText, | ||
| context: contentsContext, | ||
| highlights, | ||
| summary, | ||
| livecrawl: contentsLivecrawl, | ||
| livecrawlTimeout: contentsLivecrawlTimeout, | ||
| subpages: contentsSubpages, | ||
| subpageTarget: contentsSubpageTarget, | ||
| extras, | ||
| }, | ||
| } | ||
| : undefined | ||
| ), | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully found similar links with ID \`${response.requestId}\`.`); | ||
| return response; | ||
| }, | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.