Closed guanyouhui closed 6 days ago
The behavior you're experiencing, where Word documents and other non-image files return text content instead of the actual file, is not expected. You need to use the create_blob_message
method to return the raw data of the file.
Here is the relevant code snippet for returning a file BLOB:
def create_blob_message(self, blob: bytes, meta: dict = None, save_as: str = '') -> ToolInvokeMessage:
"""
create a blob message
:param blob: the blob
:param meta: the metadata of the file, if you know the type of the file, it is best to pass a mime_type
:param save_as: the name to save the file as
:return: the blob message
"""
Ensure that you are using this method correctly to return the actual file content. If you are currently using create_text_message
, switch to create_blob_message
for non-image files like Word documents. This method allows you to specify the raw data of the file and optionally include metadata such as the MIME type, which ensures the file is correctly interpreted by the receiving system [1][2].
Additionally, if you are using a document loader like WordExtractor
from the Dify platform, ensure that the file path is correctly handled and that the document is properly parsed. The WordExtractor
class handles the loading and parsing of .docx
files, including downloading files from URLs and extracting images and text content. Make sure your implementation aligns with these methods to avoid issues with file handling [3].
To continue talking to Dosu, mention @dosu.
See this https://github.com/langgenius/dify/issues/5346. We do not support display other file format yet.
thanks for response,and look forward to this feature being launched as soon as possible
Self Checks
Dify version
0.6.14
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
I developed a tool that obtains remote files and then displays them. This tool has been successfully run through the source code and accessed in the workflow. The test found that if the file is a picture, it can be displayed normally. If the file is a word file, etc., debugging found that the returned content is text content, not files. I would like to ask if this is the case,if there anythint about the setting problem?
✔️ Expected Behavior
No response
❌ Actual Behavior
No response