mirror of https://github.com/langgenius/dify.git
feat: add plugin id into tool api entities
This commit is contained in:
parent
45f8651a3d
commit
ccbe42eb5f
|
|
@ -33,6 +33,7 @@ class ToolProviderApiEntity(BaseModel):
|
|||
original_credentials: Optional[dict] = None
|
||||
is_team_authorization: bool = False
|
||||
allow_delete: bool = True
|
||||
plugin_id: Optional[str] = Field(default="", description="The plugin id of the tool")
|
||||
tools: list[ToolApiEntity] = Field(default_factory=list)
|
||||
labels: list[str] = Field(default_factory=list)
|
||||
|
||||
|
|
@ -51,6 +52,7 @@ class ToolProviderApiEntity(BaseModel):
|
|||
"id": self.id,
|
||||
"author": self.author,
|
||||
"name": self.name,
|
||||
"plugin_id": self.plugin_id,
|
||||
"description": self.description.to_dict(),
|
||||
"icon": self.icon,
|
||||
"label": self.label.to_dict(),
|
||||
|
|
|
|||
|
|
@ -11,10 +11,12 @@ 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) -> None:
|
||||
def __init__(self, entity: ToolProviderEntityWithPlugin, plugin_id: str, tenant_id: str) -> None:
|
||||
self.entity = entity
|
||||
self.tenant_id = tenant_id
|
||||
self.plugin_id = plugin_id
|
||||
|
||||
@property
|
||||
def provider_type(self) -> ToolProviderType:
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ class ToolManager:
|
|||
|
||||
return PluginToolProviderController(
|
||||
entity=provider_entity.declaration,
|
||||
plugin_id=provider_entity.plugin_id,
|
||||
tenant_id=tenant_id,
|
||||
)
|
||||
|
||||
|
|
@ -454,6 +455,7 @@ class ToolManager:
|
|||
return [
|
||||
PluginToolProviderController(
|
||||
entity=provider.declaration,
|
||||
plugin_id=provider.plugin_id,
|
||||
tenant_id=tenant_id,
|
||||
)
|
||||
for provider in provider_entities
|
||||
|
|
|
|||
|
|
@ -80,10 +80,14 @@ class ToolTransformService:
|
|||
type=ToolProviderType.BUILT_IN,
|
||||
masked_credentials={},
|
||||
is_team_authorization=False,
|
||||
plugin_id=None,
|
||||
tools=[],
|
||||
labels=provider_controller.tool_labels,
|
||||
)
|
||||
|
||||
if isinstance(provider_controller, PluginToolProviderController):
|
||||
result.plugin_id = provider_controller.plugin_id
|
||||
|
||||
# get credentials schema
|
||||
schema = {x.to_basic_provider_config().name: x for x in provider_controller.get_credentials_schema()}
|
||||
|
||||
|
|
@ -158,6 +162,7 @@ class ToolTransformService:
|
|||
type=ToolProviderType.WORKFLOW,
|
||||
masked_credentials={},
|
||||
is_team_authorization=True,
|
||||
plugin_id=None,
|
||||
tools=[],
|
||||
labels=labels or [],
|
||||
)
|
||||
|
|
@ -199,6 +204,7 @@ class ToolTransformService:
|
|||
zh_Hans=db_provider.name,
|
||||
),
|
||||
type=ToolProviderType.API,
|
||||
plugin_id=None,
|
||||
masked_credentials={},
|
||||
is_team_authorization=True,
|
||||
tools=[],
|
||||
|
|
|
|||
Loading…
Reference in New Issue