Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Components新增文件名称处,同时更新V2文生图参数 #711

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion python/core/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from appbuilder.core.utils import ttl_lru_cache
from appbuilder.core._client import HTTPClient, AsyncHTTPClient
from appbuilder.core.message import Message

from urllib.parse import urlparse, unquote

class ComponentArguments(BaseModel):
"""
Expand Down Expand Up @@ -581,3 +581,14 @@ def create_output(cls, type, text, role="tool", name="", visible_scope="all", ra
}]
}
return ComponentOutput(**result)

@staticmethod
def get_filename_from_url(url):
"""从给定URL中提取文件名"""
parsed_url = urlparse(url)
# 提取路径部分
path = parsed_url.path
# 从路径中获取文件名
filename = path.split('/')[-1]
# 解码URL编码的文件名
return unquote(filename)
2 changes: 1 addition & 1 deletion python/core/components/v2/text_to_image/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def tool_eval(
yield self.create_output(
type='image',
text={
'filename': "",
'filename': self.get_filename_from_url(img_urls[url_number]),
'url': img_urls[url_number],
},
raw_data=raw_data,
Expand Down
Loading