fix(tool): tool node error (#7459)

Co-authored-by: hobo.l <hobo.l@binance.com>
This commit is contained in:
luckylhb90
2024-08-21 04:04:54 +03:00
committed by GitHub
parent 8c32f8c77d
commit 9a715f6b68

View File

@@ -2,7 +2,7 @@ from collections.abc import Mapping, Sequence
from os import path from os import path
from typing import Any, cast from typing import Any, cast
from core.app.segments import ArrayAnyVariable, parser from core.app.segments import ArrayAnySegment, ArrayAnyVariable, parser
from core.callback_handler.workflow_tool_callback_handler import DifyWorkflowCallbackHandler from core.callback_handler.workflow_tool_callback_handler import DifyWorkflowCallbackHandler
from core.file.file_obj import FileTransferMethod, FileType, FileVar from core.file.file_obj import FileTransferMethod, FileType, FileVar
from core.tools.entities.tool_entities import ToolInvokeMessage, ToolParameter from core.tools.entities.tool_entities import ToolInvokeMessage, ToolParameter
@@ -142,7 +142,7 @@ class ToolNode(BaseNode):
def _fetch_files(self, variable_pool: VariablePool) -> list[FileVar]: def _fetch_files(self, variable_pool: VariablePool) -> list[FileVar]:
variable = variable_pool.get(['sys', SystemVariableKey.FILES.value]) variable = variable_pool.get(['sys', SystemVariableKey.FILES.value])
assert isinstance(variable, ArrayAnyVariable) assert isinstance(variable, ArrayAnyVariable | ArrayAnySegment)
return list(variable.value) if variable else [] return list(variable.value) if variable else []
def _convert_tool_messages(self, messages: list[ToolInvokeMessage]): def _convert_tool_messages(self, messages: list[ToolInvokeMessage]):