Files
dify-plugin-sdks/python/examples/google/provider/google.py
2024-12-02 22:18:56 +08:00

18 lines
598 B
Python

from typing import Any
from tools.google_search import GoogleSearchTool
from dify_plugin import ToolProvider
from dify_plugin.errors.tool import ToolProviderCredentialValidationError
class GoogleProvider(ToolProvider):
def _validate_credentials(self, credentials: dict[str, Any]) -> None:
try:
for _ in GoogleSearchTool.from_credentials(credentials).invoke(
tool_parameters={"query": "test", "result_type": "link"},
):
pass
except Exception as e:
raise ToolProviderCredentialValidationError(str(e)) from e