Skip to content

Commit

Permalink
Merge pull request #8 from heydevs-io/feat/codelight-firecrawl-data-s…
Browse files Browse the repository at this point in the history
…ource

feat: implement custom add firecrawl datasource
  • Loading branch information
lau-td authored Oct 1, 2024
2 parents 2339140 + f0e921b commit b11be2a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/controllers/codelight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@


from .console_api import dataset, message, conversation
from .internal_api import account, app, auth, model_config, model_providers, tenant
from .internal_api import account, app, auth, model_config, model_providers, tenant, data_source_bearer_auth
from .web import passport, conversation
37 changes: 37 additions & 0 deletions api/controllers/codelight/internal_api/data_source_bearer_auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import uuid
from flask_restful import Resource, reqparse

from controllers.codelight import api
from controllers.console.auth.error import ApiKeyAuthFailedError
from services.auth.api_key_auth_service import ApiKeyAuthService
from controllers.console.setup import setup_required
from controllers.inner_api.wraps import inner_api_only


class CodelightApiKeyAuthDataSourceBinding(Resource):
@setup_required
@inner_api_only
def post(self, tenant_id: uuid.UUID):
parser = reqparse.RequestParser()
parser.add_argument(
"category", type=str, required=True, nullable=False, location="json"
)
parser.add_argument(
"provider", type=str, required=True, nullable=False, location="json"
)
parser.add_argument(
"credentials", type=dict, required=True, nullable=False, location="json"
)
args = parser.parse_args()
ApiKeyAuthService.validate_api_key_auth_args(args)

try:
ApiKeyAuthService.create_provider_auth(tenant_id, args)
except Exception as e:
raise ApiKeyAuthFailedError(str(e))
return {"result": "success"}, 200


api.add_resource(
CodelightApiKeyAuthDataSourceBinding, "/tenants/<uuid:tenant_id>/data-sources"
)

0 comments on commit b11be2a

Please sign in to comment.