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

refactor: Update Firecrawl API parameters and default settings #13082

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/core/rag/extractor/firecrawl/firecrawl_web_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class FirecrawlWebExtractor(BaseExtractor):
api_key: The API key for Firecrawl.
base_url: The base URL for the Firecrawl API. Defaults to 'https://api.firecrawl.dev'.
mode: The mode of operation. Defaults to 'scrape'. Options are 'crawl', 'scrape' and 'crawl_return_urls'.
only_main_content: Only return the main content of the page excluding headers, navs, footers, etc.
"""

def __init__(self, url: str, job_id: str, tenant_id: str, mode: str = "crawl", only_main_content: bool = False):
def __init__(self, url: str, job_id: str, tenant_id: str, mode: str = "crawl", only_main_content: bool = True):
"""Initialize with url, api_key, base_url and mode."""
self._url = url
self.job_id = job_id
Expand Down
4 changes: 2 additions & 2 deletions api/services/auth/firecrawl/firecrawl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def validate_credentials(self):
headers = self._prepare_headers()
options = {
"url": "https://example.com",
"excludes": [],
"includes": [],
"includePaths": [],
"excludePaths": [],
"limit": 1,
"scrapeOptions": {"onlyMainContent": True},
}
Expand Down
10 changes: 4 additions & 6 deletions api/services/website_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,17 @@ def crawl_url(cls, args: dict) -> dict:
only_main_content = options.get("only_main_content", False)
if not crawl_sub_pages:
params = {
"includes": [],
"excludes": [],
"generateImgAltText": True,
"includePaths": [],
"excludePaths": [],
"limit": 1,
"scrapeOptions": {"onlyMainContent": only_main_content},
}
else:
includes = options.get("includes").split(",") if options.get("includes") else []
excludes = options.get("excludes").split(",") if options.get("excludes") else []
params = {
"includes": includes,
"excludes": excludes,
"generateImgAltText": True,
"includePaths": includes,
"excludePaths": excludes,
"limit": options.get("limit", 1),
"scrapeOptions": {"onlyMainContent": only_main_content},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ def test_firecrawl_web_extractor_crawl_mode(mocker):
base_url = "https://api.firecrawl.dev"
firecrawl_app = FirecrawlApp(api_key=api_key, base_url=base_url)
params = {
"includes": [],
"excludes": [],
"generateImgAltText": True,
"includePaths": [],
"excludePaths": [],
"maxDepth": 1,
"limit": 1,
}
Expand Down
Loading