-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Firecrawl - Extract actions #16069
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
Merged
Merged
Firecrawl - Extract actions #16069
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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 |
|---|---|---|
|
|
@@ -8,4 +8,4 @@ export default { | |
| console.log(Object.keys(this.$auth)); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
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
96 changes: 96 additions & 0 deletions
96
components/firecrawl/actions/extract-data/extract-data.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,96 @@ | ||
| import firecrawl from "../../firecrawl.app.mjs"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import { parseObjectEntries } from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| key: "firecrawl-extract-data", | ||
| name: "Extract Data", | ||
| description: "Extract structured data from one or multiple URLs. [See the documentation](https://docs.firecrawl.dev/api-reference/endpoint/extract)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| firecrawl, | ||
| urls: { | ||
| type: "string[]", | ||
| label: "URLs", | ||
| description: "An array of one or more URLs. Supports wildcards (/*) for broader crawling.", | ||
| }, | ||
| prompt: { | ||
| type: "string", | ||
| label: "Prompt", | ||
| description: "(Optional unless no schema): A natural language prompt describing the data you want or specifying how you want that data structured.", | ||
| optional: true, | ||
| }, | ||
| schema: { | ||
| type: "object", | ||
| label: "Schema", | ||
| description: "(Optional unless no prompt): A more rigid structure if you already know the JSON layout.", | ||
| optional: true, | ||
| }, | ||
| enableWebSearch: { | ||
| type: "boolean", | ||
| label: "Enable Web Search", | ||
| description: "When `true`, the extraction will use web search to find additional data", | ||
| optional: true, | ||
| }, | ||
| ignoreSitemap: { | ||
| type: "boolean", | ||
| label: "Ignore Sitemap", | ||
| description: "When true, sitemap.xml files will be ignored during website scanning", | ||
| optional: true, | ||
| }, | ||
| includeSubdomains: { | ||
| type: "boolean", | ||
| label: "Include Subdomains", | ||
| description: "When true, subdomains of the provided URLs will also be scanned", | ||
| optional: true, | ||
| }, | ||
| showSources: { | ||
| type: "boolean", | ||
| label: "Show Sources", | ||
| description: "When true, the sources used to extract the data will be included in the response", | ||
| optional: true, | ||
| }, | ||
| waitForCompletion: { | ||
| type: "boolean", | ||
| label: "Wait For Completion", | ||
| description: "Set to `true` to poll the API in 3-second intervals until the job is completed", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| if (!this.prompt && !this.schema) { | ||
| throw new ConfigurationError("Must enter one of Prompt or Schema"); | ||
| } | ||
|
|
||
| let response = await this.firecrawl.extract({ | ||
| $, | ||
| data: { | ||
| urls: this.urls, | ||
| prompt: this.prompt, | ||
| schema: this.schema && parseObjectEntries(this.schema), | ||
| enableWebSearch: this.enableWebSearch, | ||
| ignoreSitemap: this.ignoreSitemap, | ||
| includeSubdomains: this.includeSubdomains, | ||
| showSources: this.showSources, | ||
| }, | ||
| }); | ||
|
|
||
| if (this.waitForCompletion) { | ||
| const id = response.id; | ||
| const timer = (ms) => new Promise((res) => setTimeout(res, ms)); | ||
| do { | ||
| response = await this.firecrawl.getExtractStatus({ | ||
| $, | ||
| id, | ||
| }); | ||
| await timer(3000); | ||
| } while (response.status === "processing"); | ||
| } | ||
|
|
||
| if (response.success) { | ||
| $.export("$summary", "Successfully extracted data."); | ||
| } | ||
| return response; | ||
| }, | ||
| }; | ||
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
26 changes: 26 additions & 0 deletions
26
components/firecrawl/actions/get-extract-status/get-extract-status.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,26 @@ | ||
| import firecrawl from "../../firecrawl.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "firecrawl-get-extract-status", | ||
| name: "Get Extract Data", | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| description: "Obtains the status and data from a previous extract operation. [See the documentation](https://docs.firecrawl.dev/api-reference/endpoint/extract-get)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| firecrawl, | ||
| extractId: { | ||
| type: "string", | ||
| label: "Extract Job ID", | ||
| description: "The ID of the extract job", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.firecrawl.getExtractStatus({ | ||
| $, | ||
| id: this.extractId, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully retrieved status for extract (ID: ${this.extractId})`); | ||
| return response; | ||
| }, | ||
| }; | ||
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
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
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
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 |
|---|---|---|
|
|
@@ -8,4 +8,4 @@ export default { | |
| console.log(Object.keys(this.$auth)); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
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 |
|---|---|---|
|
|
@@ -8,4 +8,4 @@ export default { | |
| console.log(Object.keys(this.$auth)); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
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 |
|---|---|---|
|
|
@@ -8,4 +8,4 @@ export default { | |
| console.log(Object.keys(this.$auth)); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
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.