mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-13 06:29:07 +08:00
fix(tool): validate return type from _invoke method to ensure ToolInv… (#12079)
Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
parent
5d04638091
commit
7ae417b4b6
@ -222,6 +222,12 @@ class Tool(BaseModel, ABC):
|
||||
if not isinstance(result, list):
|
||||
result = [result]
|
||||
|
||||
if not all(isinstance(message, ToolInvokeMessage) for message in result):
|
||||
raise ValueError(
|
||||
f"Invalid return type from {self.__class__.__name__}._invoke method. "
|
||||
"Expected ToolInvokeMessage or list of ToolInvokeMessage."
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
def _transform_tool_parameters_type(self, tool_parameters: Mapping[str, Any]) -> dict[str, Any]:
|
||||
|
Loading…
x
Reference in New Issue
Block a user