Files
dify-plugin-sdks/python/dify_plugin/interfaces/datasource/__init__.py
T
Yeuoly 0922b15e54 feat: implement datasource actions and validation methods
- Added new request models for datasource actions including validation, website crawling, and content retrieval.
- Enhanced `PluginExecutor` with methods to validate datasource credentials, crawl websites, and retrieve pages and content.
- Updated `PluginRegistration` to include methods for fetching datasource provider classes and handling website and online document datasources.
- Refined the `DatasourceProvider` interface to use `Mapping` for credentials, improving type safety.
2025-05-23 19:06:18 +08:00

29 lines
1.1 KiB
Python

from collections.abc import Mapping
from typing import Any
from werkzeug import Request
class DatasourceProvider:
"""
A provider for a datasource
"""
def validate_credentials(self, credentials: Mapping[str, Any]):
return self._validate_credentials(credentials)
def _validate_credentials(self, credentials: Mapping[str, Any]):
raise NotImplementedError("This method should be implemented by a subclass")
def oauth_get_authorization_url(self, system_credentials: Mapping[str, Any]) -> str:
return self._oauth_get_authorization_url(system_credentials)
def _oauth_get_authorization_url(self, system_credentials: Mapping[str, Any]) -> str:
raise NotImplementedError("This method should be implemented by a subclass")
def oauth_get_credentials(self, system_credentials: Mapping[str, Any], request: Request) -> Mapping[str, Any]:
return self._oauth_get_credentials(system_credentials, request)
def _oauth_get_credentials(self, system_credentials: Mapping[str, Any], request: Request) -> Mapping[str, Any]:
raise NotImplementedError("This method should be implemented by a subclass")