Skip to content

Commit

Permalink
refactor: Formmating code and fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ademílson Tonato committed Jan 13, 2025
1 parent 7a29db2 commit 8c2ba17
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions api/core/rag/extractor/firecrawl/firecrawl_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def scrape_url(self, url, params=None) -> dict:
return self._extract_common_fields(data)
elif response.status_code in {402, 409, 500, 429, 408}:
self._handle_error(response, "scrape URL")
return {} # Avoid additional exception after handling error
return {} # Avoid additional exception after handling error
else:
raise Exception(f"Failed to scrape URL. Status code: {response.status_code}")

Expand Down Expand Up @@ -75,9 +75,7 @@ def check_crawl_status(self, job_id) -> dict:
storage.save(file_key, json.dumps(url_data_list).encode("utf-8"))
except Exception as e:
raise Exception(f"Error saving crawl data: {e}")
return self._format_crawl_status_response(
"completed", crawl_status_response, url_data_list
)
return self._format_crawl_status_response("completed", crawl_status_response, url_data_list)
else:
return self._format_crawl_status_response(
crawl_status_response.get("status"), crawl_status_response, []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_firecrawl_web_extractor_crawl_mode(mocker):
}
}
mocked_firecrawl = {
"jobId": "test",
"id": "test",
}
mocker.patch("requests.post", return_value=_mock_response(mocked_firecrawl))
job_id = firecrawl_app.crawl_url(url, params)
Expand Down

0 comments on commit 8c2ba17

Please sign in to comment.