Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnJyong committed Jun 14, 2024
1 parent c3fb080 commit 4f33ad2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
7 changes: 2 additions & 5 deletions api/libs/bearer_data_source.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# [REVIEW] Implement if Needed? Do we need a new type of data source
from abc import abstractmethod

Expand All @@ -19,14 +18,13 @@ def validate_bearer_data_source(self):
"""
Validate the data source
"""



class FireCrawlDataSource(BearerDataSource):
def validate_bearer_data_source(self):
TEST_CRAWL_SITE_URL = "https://www.google.com"
FIRECRAWL_API_VERSION = "v0"

test_api_endpoint = self.api_base_url.rstrip('/') + f"/{FIRECRAWL_API_VERSION}/scrape"

headers = {
Expand All @@ -42,9 +40,8 @@ def validate_bearer_data_source(self):

return response.json().get("status") == "success"


def save_credentials(self):
# save data source binding
# save data source binding
data_source_binding = DataSourceBearerBinding.query.filter(
db.and_(
DataSourceBearerBinding.tenant_id == current_user.current_tenant_id,
Expand Down
1 change: 1 addition & 0 deletions api/services/auth/api_key_auth_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ class ApiKeyAuthBase(ABC):
def __init__(self, credentials: dict):
self.credentials = credentials

@staticmethod
def validate_credentials(self):
raise NotImplementedError
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
import os
from unittest import mock

from core.rag.extractor.firecrawl.firecrawl_app import FirecrawlApp
from core.rag.extractor.firecrawl.firecrawl_web_extractor import FirecrawlWebExtractor
from core.rag.models.document import Document
from tests.unit_tests.core.rag.extractor.test_notion_extractor import _mock_response


def test_firecrawl_web_extractor_scrape_mode():
url = "https://dify.ai"
api_key = os.getenv('FIRECRAWL_API_KEY') or 'fc-'
base_url = 'https://api.firecrawl.dev'
firecrawl_app = FirecrawlApp(api_key=api_key,
base_url=base_url)
params = {
'pageOptions': {
'onlyMainContent': True,
"includeHtml": False
}
}
data = firecrawl_app.scrape_url(url, params)
print(data)
assert isinstance(data, dict)


def test_firecrawl_web_extractor_crawl_mode():
def test_firecrawl_web_extractor_crawl_mode(mocker):
url = "https://firecrawl.dev"
api_key = os.getenv('FIRECRAWL_API_KEY') or 'fc-'
base_url = 'https://api.firecrawl.dev'
Expand All @@ -39,6 +24,10 @@ def test_firecrawl_web_extractor_crawl_mode():

}
}
mocked_firecrawl = {
"jobId": "test",
}
mocker.patch("requests.post", return_value=_mock_response(mocked_firecrawl))
job_id = firecrawl_app.crawl_url(url, params)
print(job_id)
assert isinstance(job_id, str)

0 comments on commit 4f33ad2

Please sign in to comment.