mirror of
https://github.com/langgenius/dify.git
synced 2026-06-10 18:24:09 +08:00
fix: agent mode missing file cards for BINARY_LINK and FILE type tool outputs (#36746)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
a823649934
commit
3fb1d3055e
@ -283,7 +283,11 @@ class ToolEngine:
|
||||
Extract tool response binary
|
||||
"""
|
||||
for response in tool_response:
|
||||
if response.type in {ToolInvokeMessage.MessageType.IMAGE_LINK, ToolInvokeMessage.MessageType.IMAGE}:
|
||||
if response.type in {
|
||||
ToolInvokeMessage.MessageType.IMAGE_LINK,
|
||||
ToolInvokeMessage.MessageType.IMAGE,
|
||||
ToolInvokeMessage.MessageType.BINARY_LINK,
|
||||
}:
|
||||
mimetype = None
|
||||
if not response.meta:
|
||||
raise ValueError("missing meta data")
|
||||
@ -298,7 +302,11 @@ class ToolEngine:
|
||||
mimetype = guess_type_result
|
||||
|
||||
if not mimetype:
|
||||
mimetype = "image/jpeg"
|
||||
mimetype = (
|
||||
"image/jpeg"
|
||||
if response.type != ToolInvokeMessage.MessageType.BINARY_LINK
|
||||
else "application/octet-stream"
|
||||
)
|
||||
|
||||
yield ToolInvokeMessageBinary(
|
||||
mimetype=response.meta.get("mime_type", mimetype),
|
||||
|
||||
@ -172,6 +172,8 @@ class ToolFileMessageTransformer:
|
||||
meta=tool_file_meta,
|
||||
)
|
||||
else:
|
||||
if file.mime_type and "mime_type" not in tool_file_meta:
|
||||
tool_file_meta["mime_type"] = file.mime_type
|
||||
yield ToolInvokeMessage(
|
||||
type=ToolInvokeMessage.MessageType.LINK,
|
||||
message=ToolInvokeMessage.TextMessage(text=url),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user