Skip to content
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

Firecrawl - Extract actions #16069

Merged
merged 5 commits into from
Apr 1, 2025
Merged

Firecrawl - Extract actions #16069

merged 5 commits into from
Apr 1, 2025

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Mar 27, 2025

Resolves #16022

Summary by CodeRabbit

  • New Features

    • Introduced a new action enabling extraction of structured data from one or multiple URLs.
    • Added functionality to monitor the status of extraction jobs.
    • Expanded the API to support initiating and tracking data extraction processes.
  • Chores

    • Updated component versions for consistency and improved maintenance.
    • Minor formatting updates including newline additions in several files.

Copy link

vercel bot commented Mar 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Mar 31, 2025 5:06pm
pipedream-docs ⬜️ Ignored (Inspect) Mar 31, 2025 5:06pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Mar 31, 2025 5:06pm

Copy link
Contributor

coderabbitai bot commented Mar 27, 2025

Walkthrough

This PR updates several Firecrawl modules by incrementing version numbers and adding new functionality. Three existing actions (crawl-url, get-crawl-status, scrape-page) have their version properties incremented, while two new actions—extract-data and get-extract-status—are introduced for data extraction and status retrieval. Additionally, the Firecrawl app now includes methods to initiate extraction and check its status. The package version in package.json is also updated.

Changes

File(s) Change Summary
components/firecrawl/actions/... (crawl-url, get-crawl-status, scrape-page) Bumped version numbers: crawl-url (1.0.1 → 1.0.2), get-crawl-status (0.0.2 → 0.0.3), scrape-page (1.0.0 → 1.0.1).
components/firecrawl/actions/... (extract-data, get-extract-status) Added new actions: extract-data for processing URL data extraction and get-extract-status for retrieving extraction job status.
components/firecrawl/firecrawl.app.mjs Introduced extract and getExtractStatus methods to handle extraction requests and monitor extraction status.
components/firecrawl/package.json Updated package version from 1.0.0 to 1.1.0.
components/bloomerang/bloomerang.app.mjs Added a newline at the end of the file.
components/hyperbrowser/hyperbrowser.app.mjs Added a newline at the end of the file.
components/nutrient_workflow_automation/nutrient_workflow_automation.app.mjs Added a newline at the end of the file.
components/oracle_cloud_infrastructure/oracle_cloud_infrastructure.app.mjs Added a newline at the end of the file.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ExtractAction as "firecrawl-extract-data"
    participant App as "Firecrawl App"
    participant API as "Firecrawl API"
    
    Client->>ExtractAction: Trigger extraction with options (urls, prompt/schema)
    ExtractAction->>App: Call extract(opts)
    App->>API: POST /extract with opts
    API-->>App: Extraction job initiated
    App-->>ExtractAction: Return job ID & summary
    ExtractAction-->>Client: Provide extraction response
Loading
sequenceDiagram
    participant ExtractAction as "firecrawl-extract-data"
    participant API as "Firecrawl API"
    
    ExtractAction->>API: GET /extract/{id} (poll every 3 sec)
    loop While status is "processing"
        API-->>ExtractAction: Return "processing" status
        ExtractAction->>API: Poll again
    end
    API-->>ExtractAction: Final status update
    ExtractAction-->>Client: Return completed status
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement extraction functionality for Firecrawl API (/Extract) (#16022)

Suggested labels

ai-assisted, User submitted

Suggested reviewers

  • GTFalcao

Poem

I'm a code bunny with a joyful hop,
Skipping through modules with a non-stop bop.
New extraction features make my ears stand tall,
Version bumps and updates for one and all.
Hopping in code meadows, I cheer with glee 🐰✨!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/bloomerang/bloomerang.app.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

components/firecrawl/actions/crawl-url/crawl-url.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

components/firecrawl/actions/extract-data/extract-data.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

  • 3 others
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (4)
components/firecrawl/firecrawl.app.mjs (1)

72-79: Consider consistent parameter naming for ID properties.

The method looks well-implemented, but there's a minor inconsistency in parameter naming. The getCrawlStatus method uses crawlId while this method uses id. For better consistency, consider using extractId instead.

  getExtractStatus({
-    id, ...opts
+    extractId, ...opts
  }) {
    return this._makeRequest({
-      path: `/extract/${id}`,
+      path: `/extract/${extractId}`,
      ...opts,
    });
  },
components/firecrawl/actions/get-extract-status/get-extract-status.mjs (1)

17-25: Add error handling to the run method

The current implementation doesn't handle any errors that might occur during the API call. Consider adding try/catch block to provide a better user experience with meaningful error messages.

  async run({ $ }) {
+   try {
      const response = await this.firecrawl.getExtractStatus({
        $,
        id: this.extractId,
      });

      $.export("$summary", `Successfully retrieved status for extract (ID: ${this.extractId})`);
      return response;
+   } catch (error) {
+     $.export("$summary", `Failed to retrieve status for extract (ID: ${this.extractId})`);
+     throw error;
+   }
  },
components/firecrawl/actions/extract-data/extract-data.mjs (2)

37-40: Clarify the description for importSitemap property

The current description "When true, sitemap.xml files will be ignored during website scanning" is counter-intuitive. If "importSitemap" is true, one would expect sitemaps to be included, not ignored. Please verify if this is correct or update the description.

    importSitemap: {
      type: "boolean",
      label: "Import Sitemap",
-     description: "When true, sitemap.xml files will be ignored during website scanning",
+     description: "When true, sitemap.xml files will be imported and used during website scanning",
      optional: true,
    },

91-93: Handle unsuccessful extraction scenarios

The success message is only exported if response.success is true, but there's no handling for failed extractions. Consider adding a condition to export an appropriate message when the extraction is not successful.

    if (response.success) {
      $.export("$summary", "Successfully extracted data.");
+   } else {
+     $.export("$summary", `Extraction completed but was not successful: ${response.error || 'Unknown error'}`);
    }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4900ad and d4defa4.

📒 Files selected for processing (7)
  • components/firecrawl/actions/crawl-url/crawl-url.mjs (1 hunks)
  • components/firecrawl/actions/extract-data/extract-data.mjs (1 hunks)
  • components/firecrawl/actions/get-crawl-status/get-crawl-status.mjs (1 hunks)
  • components/firecrawl/actions/get-extract-status/get-extract-status.mjs (1 hunks)
  • components/firecrawl/actions/scrape-page/scrape-page.mjs (1 hunks)
  • components/firecrawl/firecrawl.app.mjs (1 hunks)
  • components/firecrawl/package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
🔇 Additional comments (6)
components/firecrawl/package.json (1)

3-3: Version bump to 1.1.0 looks appropriate.

The version increment from 1.0.0 to 1.1.0 aligns with the addition of new extract-related functionality in this update.

components/firecrawl/actions/crawl-url/crawl-url.mjs (1)

8-8: Version increment looks good.

Patch version update from 1.0.0 to 1.0.1 is appropriate for maintaining version consistency across components.

components/firecrawl/actions/scrape-page/scrape-page.mjs (1)

10-10: Version increment looks good.

Patch version update from 1.0.0 to 1.0.1 is appropriate for maintaining version consistency across components.

components/firecrawl/actions/get-crawl-status/get-crawl-status.mjs (1)

7-7: Version increment looks good.

Patch version update from 0.0.2 to 0.0.3 is appropriate for maintaining version consistency across components.

components/firecrawl/firecrawl.app.mjs (1)

65-71: Added extract method looks good.

The implementation follows the established pattern of other API methods in this file, properly utilizing the _makeRequest helper function.

components/firecrawl/actions/extract-data/extract-data.mjs (1)

62-64:

✅ Verification successful

Enhance input validation

The validation ensures either prompt or schema is provided, but doesn't check if both are provided. If having both is valid, this is fine, but it might be worth considering more precise validation if only one should be used at a time.


🌐 Web query:

Can Firecrawl API use both prompt and schema parameters simultaneously?

💡 Result:

Yes, Firecrawl API allows simultaneous use of both prompt and schema parameters to enhance structured data extraction. This combination enables users to guide the AI's output structure while providing contextual instructions:

Key Implementation Details

  1. Schema-Driven Structure
    The schema parameter defines the required output format using Pydantic models or JSON Schema, ensuring consistent data structure and type validation[15][14][3].

  2. Prompt-Based Guidance
    The prompt parameter provides natural language instructions to help the LLM understand extraction priorities and contextual nuances[7][15][3].

  3. Combined Usage Example

from firecrawl import FirecrawlApp
from pydantic import BaseModel, Field

class ProductSchema(BaseModel):
    name: str = Field(description="Product name from header")
    price: float = Field(description="Current price in USD")
    features: list[str] = Field(description="Key product features")

app = FirecrawlApp(api_key="YOUR_KEY")
data = app.scrape_url(
    'https://example-store.com/product123',
    params={
        'jsonOptions': {
            'schema': ProductSchema.model_json_schema(),
            'prompt': "Focus on technical specs and ignore marketing fluff"
        }
    }
)

Benefits of Dual Parameter Use

  • Structured Output Control
    Schema enforces strict typing and nested data formats[14][15]

  • Contextual Flexibility
    Prompts clarify ambiguous cases within the schema constraints[3][7]

  • Enhanced Accuracy
    Combination reduces LLM hallucination risks by 37% compared to prompt-only extractions[14]

This hybrid approach is particularly useful for complex extraction tasks requiring both strict formatting and human-readable instructions[15][3]. The schema handles data validation while the prompt guides content interpretation, forming a robust extraction pipeline.

Citations:


Input Validation is Correct

The current validation in components/firecrawl/actions/extract-data/extract-data.mjs (lines 62-64) correctly enforces that at least one of prompt or schema is provided. Given that the Firecrawl API supports using both parameters simultaneously to enhance structured extraction, no additional validation changes are necessary.

jcortes
jcortes previously approved these changes Mar 28, 2025
Copy link
Collaborator

@jcortes jcortes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @michelle0927 lgtm! Ready for QA!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
components/firecrawl/actions/extract-data/extract-data.mjs (1)

79-89: ⚠️ Potential issue

Implement timeout for polling mechanism

The current polling mechanism doesn't have a timeout or maximum retry count, which could lead to the action running indefinitely if the status never changes from "processing". Consider adding a timeout mechanism.

    if (this.waitForCompletion) {
      const id = response.id;
      const timer = (ms) => new Promise((res) => setTimeout(res, ms));
+     const MAX_RETRIES = 60; // 3 minutes (60 * 3 seconds)
+     let retries = 0;
      do {
        response = await this.firecrawl.getExtractStatus({
          $,
          id,
        });
        await timer(3000);
+       retries++;
+       if (retries >= MAX_RETRIES) {
+         $.export("$summary", "Extraction is taking longer than expected. You can check the status later using the Get Extract Status action.");
+         break;
+       }
      } while (response.status === "processing");
    }
🧹 Nitpick comments (3)
components/firecrawl/actions/extract-data/extract-data.mjs (3)

24-29: Consider adding schema validation or documentation

The schema property is defined as type "object" but there's no indication of what structure users should follow. Consider either adding validation for the schema format or enhancing the description with an example of the expected structure to guide users.


91-93: Enhance response summary with more details

The current success summary is generic and doesn't provide much information about what was extracted. Consider enhancing it with details about the extraction, such as the number of URLs processed or the type of data extracted.

    if (response.success) {
-     $.export("$summary", "Successfully extracted data.");
+     const urlCount = this.urls.length;
+     $.export("$summary", `Successfully extracted data from ${urlCount} URL${urlCount !== 1 ? 's' : ''}.`);
+   } else {
+     $.export("$summary", `Extraction completed with status: ${response.status || 'unknown'}`);
    }

71-71: Consider validating schema structure before sending to API

The current implementation passes the schema directly to the API after parsing. It might be beneficial to add validation to ensure the schema has the required structure before making the API call.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4defa4 and 61b182d.

📒 Files selected for processing (6)
  • components/bloomerang/bloomerang.app.mjs (1 hunks)
  • components/firecrawl/actions/crawl-url/crawl-url.mjs (1 hunks)
  • components/firecrawl/actions/extract-data/extract-data.mjs (1 hunks)
  • components/hyperbrowser/hyperbrowser.app.mjs (1 hunks)
  • components/nutrient_workflow_automation/nutrient_workflow_automation.app.mjs (1 hunks)
  • components/oracle_cloud_infrastructure/oracle_cloud_infrastructure.app.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • components/oracle_cloud_infrastructure/oracle_cloud_infrastructure.app.mjs
  • components/bloomerang/bloomerang.app.mjs
  • components/nutrient_workflow_automation/nutrient_workflow_automation.app.mjs
  • components/hyperbrowser/hyperbrowser.app.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/firecrawl/actions/crawl-url/crawl-url.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components

@michelle0927
Copy link
Collaborator Author

/approve

@michelle0927 michelle0927 merged commit a2bdd59 into master Apr 1, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-16022 branch April 1, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ACTION] Firecrawl /Extract
2 participants