From 032622d03257e56b2bc9dd6e2d55dc7cc7501e83 Mon Sep 17 00:00:00 2001 From: yepeiwen01 Date: Mon, 23 Dec 2024 11:15:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9manifests=E6=94=B9=E5=8A=A8?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E7=9A=84=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/core/components/v2/tree_mind/component.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/python/core/components/v2/tree_mind/component.py b/python/core/components/v2/tree_mind/component.py index 17b81c0b..d3f56e4c 100644 --- a/python/core/components/v2/tree_mind/component.py +++ b/python/core/components/v2/tree_mind/component.py @@ -15,6 +15,7 @@ r"""树图工具""" import json +from urllib.parse import urlparse, unquote from typing import Dict, List, Optional, Any from appbuilder.core.message import Message from appbuilder.core._client import HTTPClient @@ -83,6 +84,17 @@ def _post(self, query, **kwargs): img_link = treemind_response.info.downloadInfo.fileInfo.pic return img_link, jump_link + @staticmethod + def get_filename_from_url(url): + """从给定URL中提取文件名""" + parsed_url = urlparse(url) + # 提取路径部分 + path = parsed_url.path + # 从路径中获取文件名 + filename = path.split('/')[-1] + # 解码URL编码的文件名 + return unquote(filename) + @components_run_stream_trace def tool_eval( self, @@ -115,6 +127,7 @@ def tool_eval( img_link_result = self.create_output( type="image", text={ + "filename": self.get_filename_from_url(img_link), "url": img_link }, visible_scope='all',