mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +08:00
fix: custom tool parser
This commit is contained in:
parent
6fd0a55b00
commit
8c2dbe876f
|
@ -2,11 +2,15 @@ from pydantic import Field
|
|||
|
||||
from core.entities.provider_entities import ProviderConfig
|
||||
from core.tools.__base.tool_provider import ToolProviderController
|
||||
from core.tools.__base.tool_runtime import ToolRuntime
|
||||
from core.tools.custom_tool.tool import ApiTool
|
||||
from core.tools.entities.common_entities import I18nObject
|
||||
from core.tools.entities.tool_bundle import ApiToolBundle
|
||||
from core.tools.entities.tool_entities import (
|
||||
ApiProviderAuthType,
|
||||
ToolDescription,
|
||||
ToolEntity,
|
||||
ToolIdentity,
|
||||
ToolProviderEntity,
|
||||
ToolProviderIdentity,
|
||||
ToolProviderType,
|
||||
|
@ -86,6 +90,7 @@ class ApiToolProviderController(ToolProviderController):
|
|||
icon=db_provider.icon,
|
||||
),
|
||||
credentials_schema=credentials_schema,
|
||||
plugin_id=None,
|
||||
),
|
||||
provider_id=db_provider.id or "",
|
||||
tenant_id=db_provider.tenant_id or "",
|
||||
|
@ -103,21 +108,25 @@ class ApiToolProviderController(ToolProviderController):
|
|||
:return: the tool
|
||||
"""
|
||||
return ApiTool(
|
||||
**{
|
||||
"api_bundle": tool_bundle,
|
||||
"identity": {
|
||||
"author": tool_bundle.author,
|
||||
"name": tool_bundle.operation_id,
|
||||
"label": {"en_US": tool_bundle.operation_id, "zh_Hans": tool_bundle.operation_id},
|
||||
"icon": self.entity.identity.icon,
|
||||
"provider": self.provider_id,
|
||||
},
|
||||
"description": {
|
||||
"human": {"en_US": tool_bundle.summary or "", "zh_Hans": tool_bundle.summary or ""},
|
||||
"llm": tool_bundle.summary or "",
|
||||
},
|
||||
"parameters": tool_bundle.parameters or [],
|
||||
}
|
||||
api_bundle=tool_bundle,
|
||||
entity=ToolEntity(
|
||||
identity=ToolIdentity(
|
||||
author=tool_bundle.author,
|
||||
name=tool_bundle.operation_id or "default_tool",
|
||||
label=I18nObject(
|
||||
en_US=tool_bundle.operation_id or "default_tool",
|
||||
zh_Hans=tool_bundle.operation_id or "default_tool",
|
||||
),
|
||||
icon=self.entity.identity.icon,
|
||||
provider=self.provider_id,
|
||||
),
|
||||
description=ToolDescription(
|
||||
human=I18nObject(en_US=tool_bundle.summary or "", zh_Hans=tool_bundle.summary or ""),
|
||||
llm=tool_bundle.summary or "",
|
||||
),
|
||||
parameters=tool_bundle.parameters or [],
|
||||
),
|
||||
runtime=ToolRuntime(tenant_id=self.tenant_id),
|
||||
)
|
||||
|
||||
def load_bundled_tools(self, tools: list[ApiToolBundle]) -> list[ApiTool]:
|
||||
|
|
|
@ -459,7 +459,7 @@ class ApiToolManageService:
|
|||
user_provider.labels = labels
|
||||
|
||||
# add icon
|
||||
ToolTransformService.repack_provider(user_provider)
|
||||
ToolTransformService.repack_provider(tenant_id=tenant_id, provider=user_provider)
|
||||
|
||||
tools = provider_controller.get_tools(tenant_id=tenant_id)
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ class WorkflowToolManageService:
|
|||
user_tool_provider = ToolTransformService.workflow_provider_to_user_provider(
|
||||
provider_controller=tool, labels=labels.get(tool.provider_id, [])
|
||||
)
|
||||
ToolTransformService.repack_provider(user_tool_provider)
|
||||
ToolTransformService.repack_provider(tenant_id=tenant_id, provider=user_tool_provider)
|
||||
user_tool_provider.tools = [
|
||||
ToolTransformService.convert_tool_entity_to_api_entity(
|
||||
tool=tool.get_tools(tenant_id)[0],
|
||||
|
|
Loading…
Reference in New Issue
Block a user