feat: get debugging key
This commit is contained in:
parent
9693b5ad0c
commit
2223dfb266
@ -56,4 +56,4 @@ from .explore import (
|
||||
from .tag import tags
|
||||
|
||||
# Import workspace controllers
|
||||
from .workspace import account, load_balancing_config, members, model_providers, models, tool_providers, workspace
|
||||
from .workspace import account, load_balancing_config, members, model_providers, models, tool_providers, workspace, plugin
|
||||
|
27
api/controllers/console/workspace/plugin.py
Normal file
27
api/controllers/console/workspace/plugin.py
Normal file
@ -0,0 +1,27 @@
|
||||
from flask_login import current_user
|
||||
from flask_restful import Resource
|
||||
from werkzeug.exceptions import Forbidden
|
||||
|
||||
from controllers.console import api
|
||||
from controllers.console.setup import setup_required
|
||||
from controllers.console.wraps import account_initialization_required
|
||||
from libs.login import login_required
|
||||
from services.plugin.plugin_debugging_service import PluginDebuggingService
|
||||
|
||||
|
||||
class PluginDebuggingKeyApi(Resource):
|
||||
@setup_required
|
||||
@login_required
|
||||
@account_initialization_required
|
||||
def get(self):
|
||||
user = current_user
|
||||
if not user.is_admin_or_owner:
|
||||
raise Forbidden()
|
||||
|
||||
tenant_id = user.current_tenant_id
|
||||
return {
|
||||
"key": PluginDebuggingService.get_plugin_debugging_key(tenant_id)
|
||||
}
|
||||
|
||||
|
||||
api.add_resource(PluginDebuggingKeyApi, "/workspaces/current/plugin/debugging-key")
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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}')
|
8
api/services/plugin/plugin_debugging_service.py
Normal file
8
api/services/plugin/plugin_debugging_service.py
Normal file
@ -0,0 +1,8 @@
|
||||
from core.plugin.manager.debugging import PluginDebuggingManager
|
||||
|
||||
|
||||
class PluginDebuggingService:
|
||||
@staticmethod
|
||||
def get_plugin_debugging_key(tenant_id: str) -> str:
|
||||
manager = PluginDebuggingManager()
|
||||
return manager.get_debugging_key(tenant_id)
|
Loading…
Reference in New Issue
Block a user