Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Feb 24, 2025
1 parent 4446d04 commit 7fdd7c8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/backend/base/langflow/components/firecrawl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from .firecrawl_map_api import FirecrawlMapApi
from .firecrawl_scrape_api import FirecrawlScrapeApi

__all__ = ["FirecrawlCrawlApi", "FirecrawlScrapeApi", "FirecrawlMapApi", "FirecrawlExtractApi"]
__all__ = ["FirecrawlCrawlApi", "FirecrawlExtractApi", "FirecrawlMapApi", "FirecrawlScrapeApi"]
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import uuid

from langflow.custom import Component
from langflow.io import DataInput, IntInput, MultilineInput, Output, SecretStrInput, StrInput
from langflow.schema import Data


class FirecrawlCrawlApi(Component):
display_name: str = "FirecrawlCrawlApi"
description: str = "Firecrawl Crawl API."
Expand Down Expand Up @@ -84,4 +86,4 @@ def crawl(self) -> Data:

app = FirecrawlApp(api_key=self.api_key)
crawl_result = app.crawl_url(self.url, params=params, idempotency_key=self.idempotency_key)
return Data(data={"results": crawl_result})
return Data(data={"results": crawl_result})
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from langflow.custom import Component
from langflow.io import (
BoolInput,
DataInput,
MultilineInput,
Output,
SecretStrInput,
StrInput,
BoolInput,
)
from langflow.schema import Data


class FirecrawlExtractApi(Component):
display_name: str = "FirecrawlExtractApi"
description: str = "Firecrawl Extract API."
Expand Down Expand Up @@ -88,9 +88,9 @@ def extract(self) -> Data:
# Validate URLs
if not self.urls:
raise ValueError("URLs are required")

Check failure on line 90 in src/backend/base/langflow/components/firecrawl/firecrawl_extract_api.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (TRY003)

src/backend/base/langflow/components/firecrawl/firecrawl_extract_api.py:90:19: TRY003 Avoid specifying long messages outside the exception class

Check failure on line 90 in src/backend/base/langflow/components/firecrawl/firecrawl_extract_api.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (EM101)

src/backend/base/langflow/components/firecrawl/firecrawl_extract_api.py:90:30: EM101 Exception must not use a string literal, assign to variable first

# Split and validate URLs (handle both commas and newlines)
urls = [url.strip() for url in self.urls.replace('\n', ',').split(',') if url.strip()]
urls = [url.strip() for url in self.urls.replace("\n", ",").split(",") if url.strip()]
if not urls:
raise ValueError("No valid URLs provided")

Check failure on line 95 in src/backend/base/langflow/components/firecrawl/firecrawl_extract_api.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (TRY003)

src/backend/base/langflow/components/firecrawl/firecrawl_extract_api.py:95:19: TRY003 Avoid specifying long messages outside the exception class

Check failure on line 95 in src/backend/base/langflow/components/firecrawl/firecrawl_extract_api.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (EM101)

src/backend/base/langflow/components/firecrawl/firecrawl_extract_api.py:95:30: EM101 Exception must not use a string literal, assign to variable first

Expand All @@ -100,7 +100,7 @@ def extract(self) -> Data:

# Get the prompt text (handling both string and multiline input)
prompt_text = self.prompt.strip()

# Enhance the prompt to encourage comprehensive extraction
enhanced_prompt = prompt_text
if "schema" not in prompt_text.lower():
Expand All @@ -127,11 +127,11 @@ def extract(self) -> Data:
# Skip invalid schema without raising an error
print("Warning: Provided schema is not in the correct format. Proceeding without schema.")

Check failure on line 128 in src/backend/base/langflow/components/firecrawl/firecrawl_extract_api.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (T201)

src/backend/base/langflow/components/firecrawl/firecrawl_extract_api.py:128:21: T201 `print` found
except Exception as e:

Check failure on line 129 in src/backend/base/langflow/components/firecrawl/firecrawl_extract_api.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (BLE001)

src/backend/base/langflow/components/firecrawl/firecrawl_extract_api.py:129:20: BLE001 Do not catch blind exception: `Exception`
print(f"Warning: Could not process schema: {str(e)}. Proceeding without schema.")
print(f"Warning: Could not process schema: {e!s}. Proceeding without schema.")

try:
app = FirecrawlApp(api_key=self.api_key)
extract_result = app.extract(urls, params=params)
return Data(data=extract_result)
except Exception as e:
raise ValueError(f"Error during extraction: {str(e)}")
raise ValueError(f"Error during extraction: {e!s}")
24 changes: 10 additions & 14 deletions src/backend/base/langflow/components/firecrawl/firecrawl_map_api.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from langflow.custom import Component
from langflow.io import (
DataInput,
BoolInput,
MultilineInput,
Output,
SecretStrInput,
StrInput,
BoolInput,
)
from langflow.schema import Data


class FirecrawlMapApi(Component):
display_name: str = "FirecrawlMapApi"
description: str = "Firecrawl Map API."
Expand Down Expand Up @@ -63,9 +62,9 @@ def map(self) -> Data:
# Validate URLs
if not self.urls:
raise ValueError("URLs are required")

# Split and validate URLs (handle both commas and newlines)
urls = [url.strip() for url in self.urls.replace('\n', ',').split(',') if url.strip()]
urls = [url.strip() for url in self.urls.replace("\n", ",").split(",") if url.strip()]
if not urls:
raise ValueError("No valid URLs provided")

Expand All @@ -76,17 +75,14 @@ def map(self) -> Data:
}

app = FirecrawlApp(api_key=self.api_key)

# Map all provided URLs and combine results
combined_links = []
for url in urls:
result = app.map_url(url, params=params)
if isinstance(result, dict) and 'links' in result:
combined_links.extend(result['links'])

map_result = {
'success': True,
'links': combined_links
}
if isinstance(result, dict) and "links" in result:
combined_links.extend(result["links"])

map_result = {"success": True, "links": combined_links}

return Data(data=map_result)
return Data(data=map_result)
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
)
from langflow.schema import Data


class FirecrawlScrapeApi(Component):
display_name: str = "FirecrawlScrapeApi"
description: str = "Firecrawl Scrape API."
Expand Down Expand Up @@ -70,4 +71,4 @@ def scrape(self) -> Data:

app = FirecrawlApp(api_key=self.api_key)
results = app.scrape_url(self.url, params=params)
return Data(data=results)
return Data(data=results)

0 comments on commit 7fdd7c8

Please sign in to comment.