feat: add cognee-community-tasks-firecrawl - #214
Open
JuampiHernandez wants to merge 1 commit into
Open
JuampiHernandez wants to merge 1 commit into
JuampiHernandez wants to merge 1 commit into
Conversation
Signed-off-by: Juampi <JuampiHernandez@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hi, I'm Juan from the Firecrawl team.
Summary
This adds
cognee-community-tasks-firecrawlunderpackages/task/firecrawl_tasks, with four async tasks,scrape_urls,scrape_and_add,search_webandsearch_and_add, plus one row for it in the root README package table.Scrape turns a URL, including JavaScript-rendered pages and PDFs, into markdown for cognee to chunk and graph. Search returns each result page's markdown in the same call, so
search_and_adddoes not need a second request per result.Why
This repo already uses Firecrawl. The dlt and Qdrant docs assistants in
experimental/scrape their docs with hand-writtenrequestscalls to the old v1 scrape endpoint, with the key set as a constant at the top of each script. This package turns that step into a tested cognee task, so the same flow becomesscrape_and_add(urls)with the key read from the environment, on the current v2 API. Search adds the case where you start from a question instead of a list of URLs.Package
It follows the shape of the existing
exa_taskspackage, with a typed result dataclass, a client builder that reads the key from the environment,cognee.addthencognee.cognify, mocked tests, an example and a README. It uses the async client from the officialfirecrawl-pySDK and requiresFIRECRAWL_API_KEY(or anapi_keyargument). cognee is pinned to 1.6.1, the version #210 moved the adapters to.Example
scrape_urlsruns pages concurrently under aconcurrencycap (default 5) and keeps input order. A URL that fails does not stop the batch, it comes back with emptycontentand the SDK's error inerror. An invalid key or exhausted credits raises the SDK error instead, because it would fail every URL. The*_and_addtasks skip pages with no markdown or an HTTP error status, and cognify only the dataset they wrote to.Tested
All of this ran inside
packages/task/firecrawl_tasks.uv sync --all-extrasruff check .andruff format --check .are clean with ruff 0.16.2 and 0.16.9 (the version the last ruff workflow run installed)uv run --with pytest pytest tests -qgives 19 passed on Python 3.11, 3.12 and 3.13, withAsyncFirecrawlandcogneemocked and fixtures built from the SDK's ownDocumentandSearchDatatypesuv run python ./examples/example.pyran to completion, and a longer live run scraped the cognee docs and the Attention Is All You Need PDF (3.6k and 44.5k chars of markdown) and ransearch_and_addwith 3 results.cognee.searchanswered from both datasets. A bad key raised the SDK'sUnauthorizedErrorand a missing key raised aValueErrornamingFIRECRAWL_API_KEYI did not add a job to
community_task_tests.yml, since it would need a Firecrawl secret in the repo. Happy to add one if you want it.If you would rather start with a scrape-only package, I can drop the two search tasks from this PR.
I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin.