admin 管理员组

文章数量: 1184232

在某些场景中,我们需要直接传一个文件到工作流中,那么如何构建API接口进行请求,我觉得在Dify官方文档上面没有说得很明白。以apifox为例

在上面这样一个工作流中,开始节点需要接收一个音频文件,那么如何构建请求。首先看一下官方给的示例,这里注意如果采用 local_file 模式,需要先调用上传文件接口,然后拿到文件id。

第一步:根据官网给的示例,构建请求拿到id

Apifox示例:

第二步:发送请求

注意:在Chatflow中更容易误导,官网给的如下

curl -X POST 'https://api.dify.ai/v1/chat-messages' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "inputs": {},
    "query": "What are the specs of the iPhone 13 Pro Max?",
    "response_mode": "streaming",
    "conversation_id": "",
    "user": "abc-123",
    "files": [
      {
        "type": "image",
        "transfer_method": "remote_url",
        "url": "https://cloud.dify.ai/logo/logo-site.png"
      }
    ]
}'

实际请求如下,file 需要放到 inputs 里面

如果还有其他疑问,欢迎留言探讨!

本文标签: 工作流 文件 Dify 有小坑 api