| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- from typing import Any
- from dify_plugin import ToolProvider
- from dify_plugin.errors.tool import ToolProviderCredentialValidationError
- class ImageFitzProvider(ToolProvider):
-
- def _validate_credentials(self, credentials: dict[str, Any]) -> None:
- try:
- """
- IMPLEMENT YOUR VALIDATION HERE
- """
- except Exception as e:
- raise ToolProviderCredentialValidationError(str(e))
- #########################################################################################
- # If OAuth is supported, uncomment the following functions.
- # Warning: please make sure that the sdk version is 0.4.2 or higher.
- #########################################################################################
- # def _oauth_get_authorization_url(self, redirect_uri: str, system_credentials: Mapping[str, Any]) -> str:
- # """
- # Generate the authorization URL for image_fitz OAuth.
- # """
- # try:
- # """
- # IMPLEMENT YOUR AUTHORIZATION URL GENERATION HERE
- # """
- # except Exception as e:
- # raise ToolProviderOAuthError(str(e))
- # return ""
-
- # def _oauth_get_credentials(
- # self, redirect_uri: str, system_credentials: Mapping[str, Any], request: Request
- # ) -> Mapping[str, Any]:
- # """
- # Exchange code for access_token.
- # """
- # try:
- # """
- # IMPLEMENT YOUR CREDENTIALS EXCHANGE HERE
- # """
- # except Exception as e:
- # raise ToolProviderOAuthError(str(e))
- # return dict()
- # def _oauth_refresh_credentials(
- # self, redirect_uri: str, system_credentials: Mapping[str, Any], credentials: Mapping[str, Any]
- # ) -> OAuthCredentials:
- # """
- # Refresh the credentials
- # """
- # return OAuthCredentials(credentials=credentials, expires_at=-1)
|