mirror of
https://github.com/langgenius/dify.git
synced 2026-04-21 19:27:40 +08:00
refactor: using DeclarativeBase as parent class of models, refactored tools
This commit is contained in:
@ -11,12 +11,10 @@ from core.tools.plugin_tool.tool import PluginTool
|
||||
class PluginToolProviderController(BuiltinToolProviderController):
|
||||
entity: ToolProviderEntityWithPlugin
|
||||
tenant_id: str
|
||||
plugin_id: str
|
||||
|
||||
def __init__(self, entity: ToolProviderEntityWithPlugin, tenant_id: str, plugin_id: str) -> None:
|
||||
def __init__(self, entity: ToolProviderEntityWithPlugin, tenant_id: str) -> None:
|
||||
self.entity = entity
|
||||
self.tenant_id = tenant_id
|
||||
self.plugin_id = plugin_id
|
||||
|
||||
@property
|
||||
def provider_type(self) -> ToolProviderType:
|
||||
@ -35,7 +33,6 @@ class PluginToolProviderController(BuiltinToolProviderController):
|
||||
if not manager.validate_provider_credentials(
|
||||
tenant_id=self.tenant_id,
|
||||
user_id=user_id,
|
||||
plugin_id=self.plugin_id,
|
||||
provider=self.entity.identity.name,
|
||||
credentials=credentials,
|
||||
):
|
||||
@ -54,7 +51,6 @@ class PluginToolProviderController(BuiltinToolProviderController):
|
||||
entity=tool_entity,
|
||||
runtime=ToolRuntime(tenant_id=self.tenant_id),
|
||||
tenant_id=self.tenant_id,
|
||||
plugin_id=self.plugin_id,
|
||||
)
|
||||
|
||||
def get_tools(self) -> list[PluginTool]:
|
||||
@ -66,7 +62,6 @@ class PluginToolProviderController(BuiltinToolProviderController):
|
||||
entity=tool_entity,
|
||||
runtime=ToolRuntime(tenant_id=self.tenant_id),
|
||||
tenant_id=self.tenant_id,
|
||||
plugin_id=self.plugin_id,
|
||||
)
|
||||
for tool_entity in self.entity.tools
|
||||
]
|
||||
|
||||
@ -9,12 +9,10 @@ from core.tools.entities.tool_entities import ToolEntity, ToolInvokeMessage, Too
|
||||
|
||||
class PluginTool(Tool):
|
||||
tenant_id: str
|
||||
plugin_id: str
|
||||
|
||||
def __init__(self, entity: ToolEntity, runtime: ToolRuntime, tenant_id: str, plugin_id: str) -> None:
|
||||
def __init__(self, entity: ToolEntity, runtime: ToolRuntime, tenant_id: str) -> None:
|
||||
super().__init__(entity, runtime)
|
||||
self.tenant_id = tenant_id
|
||||
self.plugin_id = plugin_id
|
||||
|
||||
@property
|
||||
def tool_provider_type(self) -> ToolProviderType:
|
||||
@ -25,7 +23,6 @@ class PluginTool(Tool):
|
||||
return manager.invoke(
|
||||
tenant_id=self.tenant_id,
|
||||
user_id=user_id,
|
||||
plugin_id=self.plugin_id,
|
||||
tool_provider=self.entity.identity.provider,
|
||||
tool_name=self.entity.identity.name,
|
||||
credentials=self.runtime.credentials,
|
||||
@ -37,5 +34,4 @@ class PluginTool(Tool):
|
||||
entity=self.entity,
|
||||
runtime=runtime,
|
||||
tenant_id=self.tenant_id,
|
||||
plugin_id=self.plugin_id,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user