langgenius / dify-docs

The open-source repo for docs.dify.ai
Creative Commons Attribution 4.0 International
179 stars 166 forks source link

About the file upload in API #361

Open sandycs-protoss opened 19 hours ago

sandycs-protoss commented 19 hours ago

The workflow supports file upload functionality, but how do I pass the file when calling the API? It seems that the files field in the API is not recognized by the workflow system. Below is the data I used to send to the API. The image_file is a variable I've set in the start of the workflow { "inputs": { "image_file":"https://img.calceus.org/wechat/2053058426234668218.png?x-oss-process=image/resize,w_1500" }, "query": "Analyse this picture for me", "response_mode": "blocking", "conversation_id": "", "auto_generate_name": false, "user": "wechatbot",

"files": [ { "type": "image", "transfer_method": "remote_url", "url": "https://img.calceus.org/wechat/2053058426234668218.png?x-oss-process=image/resize,w_1500" } ] }

dosubot[bot] commented 19 hours ago

Hey @sandycs-protoss! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this together!

To pass a file when calling the API in a workflow system where the files field is not recognized, you should create a custom file variable in the "Start" node of your Workflow application. This allows you to upload, parse, and reference files as File variables within the workflow. You can choose either a "Single File" or "File List" as the field type for the variable. After uploading, use a "Document Extractor" node to convert the file content into a format that can be processed by LLMs. This approach is recommended as the sys.files variable is marked as LEGACY and will be deprecated in the future [1][2].

To continue talking to Dosu, mention @dosu.