feat: get debugging key

This commit is contained in:
Yeuoly
2024-09-20 15:08:39 +08:00
parent 9693b5ad0c
commit 2223dfb266
6 changed files with 45 additions and 6 deletions

View File

@ -10,7 +10,7 @@ from configs import dify_config
from core.plugin.entities.plugin_daemon import PluginDaemonBasicResponse
plugin_daemon_inner_api_baseurl = dify_config.PLUGIN_API_URL
plugin_daemon_inner_api_key = dify_config.INNER_API_KEY_FOR_PLUGIN
plugin_daemon_inner_api_key = dify_config.PLUGIN_API_KEY
T = TypeVar("T", bound=(BaseModel | dict))
@ -69,9 +69,9 @@ class BasePluginManager:
response = self._request(method, path, headers, data)
rep = PluginDaemonBasicResponse[type](**response.json())
if rep.code != 0:
raise Exception(f"got error from plugin daemon: {rep.message}, code: {rep.code}")
raise ValueError(f"got error from plugin daemon: {rep.message}, code: {rep.code}")
if rep.data is None:
raise Exception("got empty data from plugin daemon")
raise ValueError("got empty data from plugin daemon")
return rep.data

View File

@ -12,6 +12,6 @@ class PluginDebuggingManager(BasePluginManager):
class Response(BaseModel):
key: str
response = self._request_with_plugin_daemon_response("POST", f"/plugin/{tenant_id}/debugging/key", Response)
response = self._request_with_plugin_daemon_response("POST", f"plugin/{tenant_id}/debugging/key", Response)
return response.key

View File

@ -2,4 +2,8 @@ from core.plugin.manager.base import BasePluginManager
class PluginToolManager(BasePluginManager):
pass
def fetch_tool_providers(self, asset_id: str) -> list[str]:
"""
Fetch tool providers for the given asset.
"""
response = self._request('GET', f'/plugin/asset/{asset_id}')