mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-07-22 10:25:23 -04:00
0922b15e54
- 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.
29 lines
1.1 KiB
Python
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")
|