From 29e3c3061c903bfa6d08ba2486f87b68874a6e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=9E=E6=B3=95=E6=93=8D=E4=BD=9C?= Date: Thu, 1 Aug 2024 13:21:49 +0800 Subject: [PATCH] fix: remote image not display in answer node (#6867) --- api/core/tools/provider/builtin/duckduckgo/tools/ddgo_img.py | 2 ++ api/core/workflow/nodes/tool/tool_node.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_img.py b/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_img.py index ed873cdcf6..bca53f6b4b 100644 --- a/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_img.py +++ b/api/core/tools/provider/builtin/duckduckgo/tools/ddgo_img.py @@ -2,6 +2,7 @@ from typing import Any from duckduckgo_search import DDGS +from core.file.file_obj import FileTransferMethod from core.tools.entities.tool_entities import ToolInvokeMessage from core.tools.tool.builtin_tool import BuiltinTool @@ -21,6 +22,7 @@ class DuckDuckGoImageSearchTool(BuiltinTool): response = DDGS().images(**query_dict) result = [] for res in response: + res['transfer_method'] = FileTransferMethod.REMOTE_URL msg = ToolInvokeMessage(type=ToolInvokeMessage.MessageType.IMAGE_LINK, message=res.get('image'), save_as='', diff --git a/api/core/workflow/nodes/tool/tool_node.py b/api/core/workflow/nodes/tool/tool_node.py index c03a17468a..969b1c241e 100644 --- a/api/core/workflow/nodes/tool/tool_node.py +++ b/api/core/workflow/nodes/tool/tool_node.py @@ -174,13 +174,14 @@ class ToolNode(BaseNode): ext = path.splitext(url)[1] mimetype = response.meta.get('mime_type', 'image/jpeg') filename = response.save_as or url.split('/')[-1] + transfer_method = response.meta.get('transfer_method', FileTransferMethod.TOOL_FILE) # get tool file id tool_file_id = url.split('/')[-1].split('.')[0] result.append(FileVar( tenant_id=self.tenant_id, type=FileType.IMAGE, - transfer_method=FileTransferMethod.TOOL_FILE, + transfer_method=transfer_method, url=url, related_id=tool_file_id, filename=filename,