This commit is contained in:
Blackoutta 2026-08-15 11:16:30 +08:00 committed by GitHub
commit 188ae9105f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 272 additions and 40 deletions

View File

@ -918,7 +918,7 @@ Chat applications support session persistence, allowing previous chat history to
### Response
- `form_content` (string) Rendered form content (markdown/plain text)
- `inputs` (array[object]) Form input definitions
- `inputs` (array[object]) Form input definitions. Supported `type` values include `paragraph`, `select`, `file`, and `file-list`; see the example for each shape.
- `resolved_default_values` (object) Default values resolved to strings
- `user_actions` (array[object]) Action buttons
- `expiration_time` (timestamp) Form expiration time (Unix seconds)
@ -940,18 +940,43 @@ Chat applications support session persistence, allowing previous chat history to
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{
"form_content": "Please confirm the final answer: {{#$output.answer#}}",
"form_content": "Please upload a file list:\n{{#$output.files#}}\n\nPlease upload a single file:\n{{#$output.a_single_file#}}\n\nPlease select an option:\n{{#$output.my_single_choice#}}\n\nPlease enter a paragraph:\n{{#$output.my_paragraph#}}\n",
"inputs": [
{
"label": "Answer",
"type": "text-input",
"required": true,
"output_variable_name": "answer"
"output_variable_name": "files",
"allowed_file_types": ["image", "document", "audio", "video"],
"allowed_file_extensions": [],
"allowed_file_upload_methods": ["local_file", "remote_url"],
"type": "file-list",
"number_limits": 5
},
{
"output_variable_name": "a_single_file",
"allowed_file_types": ["image", "document", "audio", "video"],
"allowed_file_extensions": [],
"allowed_file_upload_methods": ["local_file", "remote_url"],
"type": "file"
},
{
"output_variable_name": "my_single_choice",
"type": "select",
"option_source": {
"type": "constant",
"selector": [],
"value": ["apple", "orange", "strawberry"]
}
},
{
"output_variable_name": "my_paragraph",
"type": "paragraph",
"default": {
"type": "constant",
"selector": [],
"value": "this is a default value for my paragraph"
}
}
],
"resolved_default_values": {
"answer": "Initial value"
},
"resolved_default_values": {},
"user_actions": [
{ "id": "approve", "title": "Approve", "button_style": "primary" },
{ "id": "reject", "title": "Reject", "button_style": "warning" }
@ -983,6 +1008,19 @@ Chat applications support session persistence, allowing previous chat history to
- `action` (string) Required, selected action ID from `user_actions`.
- `user` (string) Required, end-user identifier.
For file fields, upload local files with [`POST /files/upload`](#file-upload) first, then use the returned file `id` as `upload_file_id`. The `user` must be the same in both requests.
- `file-list` fields expect an array of file objects.
- `file` fields expect one file object.
- For each submitted file object, set `type` to one of the field's `allowed_file_types`: `image`, `document`, `audio`, or `video`.
When `remote_url` is allowed, you can submit a file URL directly:
<CodeGroup title="Remote URL file object" targetCode={`{
"type": "image",
"transfer_method": "remote_url",
"url": "https://example.com/image.png"
}`} />
### Response
Returns an empty object on success.
@ -1001,7 +1039,27 @@ Chat applications support session persistence, allowing previous chat history to
--header 'Authorization: Bearer {api_key}' \\
--header 'Content-Type: application/json' \\
--data-raw '{
"inputs": {"answer": "Approved answer"},
"inputs": {
"files": [
{
"type": "image",
"transfer_method": "local_file",
"upload_file_id": "{file_id_1}"
},
{
"type": "document",
"transfer_method": "local_file",
"upload_file_id": "{file_id_2}"
}
],
"a_single_file": {
"type": "image",
"transfer_method": "local_file",
"upload_file_id": "{file_id_3}"
},
"my_single_choice": "apple",
"my_paragraph": "hey welcome to Dify!"
},
"action": "approve",
"user": "abc-123"
}'`}

View File

@ -912,7 +912,7 @@ import { WorkflowVersionApiUpgradeNotice } from '../workflow-version-api-upgrade
### Response
- `form_content` (string) 已渲染的表单内容markdown/plain text
- `inputs` (array[object]) 表单输入项定义
- `inputs` (array[object]) 表单输入项定义。支持的 `type` 包括 `paragraph`、`select`、`file` 和 `file-list`;各类型结构见示例。
- `resolved_default_values` (object) 已解析的默认值(字符串)
- `user_actions` (array[object]) 操作按钮列表
- `expiration_time` (timestamp) 表单过期时间Unix 秒)
@ -934,18 +934,43 @@ import { WorkflowVersionApiUpgradeNotice } from '../workflow-version-api-upgrade
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{
"form_content": "请确认最终结果:{{#$output.answer#}}",
"form_content": "Please upload a file list:\n{{#$output.files#}}\n\nPlease upload a single file:\n{{#$output.a_single_file#}}\n\nPlease select an option:\n{{#$output.my_single_choice#}}\n\nPlease enter a paragraph:\n{{#$output.my_paragraph#}}\n",
"inputs": [
{
"label": "答案",
"type": "text-input",
"required": true,
"output_variable_name": "answer"
"output_variable_name": "files",
"allowed_file_types": ["image", "document", "audio", "video"],
"allowed_file_extensions": [],
"allowed_file_upload_methods": ["local_file", "remote_url"],
"type": "file-list",
"number_limits": 5
},
{
"output_variable_name": "a_single_file",
"allowed_file_types": ["image", "document", "audio", "video"],
"allowed_file_extensions": [],
"allowed_file_upload_methods": ["local_file", "remote_url"],
"type": "file"
},
{
"output_variable_name": "my_single_choice",
"type": "select",
"option_source": {
"type": "constant",
"selector": [],
"value": ["apple", "orange", "strawberry"]
}
},
{
"output_variable_name": "my_paragraph",
"type": "paragraph",
"default": {
"type": "constant",
"selector": [],
"value": "this is a default value for my paragraph"
}
}
],
"resolved_default_values": {
"answer": "初始值"
},
"resolved_default_values": {},
"user_actions": [
{ "id": "approve", "title": "通过", "button_style": "primary" },
{ "id": "reject", "title": "拒绝", "button_style": "warning" }
@ -977,6 +1002,19 @@ import { WorkflowVersionApiUpgradeNotice } from '../workflow-version-api-upgrade
- `action` (string) 必填,从 `user_actions` 中选择的动作 ID
- `user` (string) 必填,终端用户标识
对于文件字段,请先通过 [`POST /files/upload`](#files-upload) 上传本地文件,然后使用返回的文件 `id` 作为 `upload_file_id`。两次请求中的 `user` 必须保持一致。
- `file-list` 字段提交文件对象数组。
- `file` 字段提交单个文件对象。
- 提交的每个文件对象都需要设置 `type`,其值必须来自该字段的 `allowed_file_types``image`、`document`、`audio` 或 `video`。
当允许 `remote_url` 时,也可以直接提交文件 URL
<CodeGroup title="远程 URL 文件对象" targetCode={`{
"type": "image",
"transfer_method": "remote_url",
"url": "https://example.com/image.png"
}`} />
### Response
成功时返回空对象。
@ -995,7 +1033,27 @@ import { WorkflowVersionApiUpgradeNotice } from '../workflow-version-api-upgrade
--header 'Authorization: Bearer {api_key}' \\
--header 'Content-Type: application/json' \\
--data-raw '{
"inputs": {"answer": "已确认答案"},
"inputs": {
"files": [
{
"type": "image",
"transfer_method": "local_file",
"upload_file_id": "{file_id_1}"
},
{
"type": "document",
"transfer_method": "local_file",
"upload_file_id": "{file_id_2}"
}
],
"a_single_file": {
"type": "image",
"transfer_method": "local_file",
"upload_file_id": "{file_id_3}"
},
"my_single_choice": "apple",
"my_paragraph": "hey welcome to Dify!"
},
"action": "approve",
"user": "abc-123"
}'`}

View File

@ -1017,7 +1017,7 @@ Workflow applications offers non-session support and is ideal for translation, a
### Response
- `form_content` (string) Rendered form content (markdown/plain text)
- `inputs` (array[object]) Form input definitions
- `inputs` (array[object]) Form input definitions. Supported `type` values include `paragraph`, `select`, `file`, and `file-list`; see the example for each shape.
- `resolved_default_values` (object) Default values resolved to strings
- `user_actions` (array[object]) Action buttons
- `expiration_time` (timestamp) Form expiration time (Unix seconds)
@ -1039,18 +1039,43 @@ Workflow applications offers non-session support and is ideal for translation, a
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{
"form_content": "Please confirm the final answer: {{#$output.answer#}}",
"form_content": "Please upload a file list:\n{{#$output.files#}}\n\nPlease upload a single file:\n{{#$output.a_single_file#}}\n\nPlease select an option:\n{{#$output.my_single_choice#}}\n\nPlease enter a paragraph:\n{{#$output.my_paragraph#}}\n",
"inputs": [
{
"label": "Answer",
"type": "text-input",
"required": true,
"output_variable_name": "answer"
"output_variable_name": "files",
"allowed_file_types": ["image", "document", "audio", "video"],
"allowed_file_extensions": [],
"allowed_file_upload_methods": ["local_file", "remote_url"],
"type": "file-list",
"number_limits": 5
},
{
"output_variable_name": "a_single_file",
"allowed_file_types": ["image", "document", "audio", "video"],
"allowed_file_extensions": [],
"allowed_file_upload_methods": ["local_file", "remote_url"],
"type": "file"
},
{
"output_variable_name": "my_single_choice",
"type": "select",
"option_source": {
"type": "constant",
"selector": [],
"value": ["apple", "orange", "strawberry"]
}
},
{
"output_variable_name": "my_paragraph",
"type": "paragraph",
"default": {
"type": "constant",
"selector": [],
"value": "this is a default value for my paragraph"
}
}
],
"resolved_default_values": {
"answer": "Initial value"
},
"resolved_default_values": {},
"user_actions": [
{ "id": "approve", "title": "Approve", "button_style": "primary" },
{ "id": "reject", "title": "Reject", "button_style": "warning" }
@ -1082,6 +1107,19 @@ Workflow applications offers non-session support and is ideal for translation, a
- `action` (string) Required, selected action ID from `user_actions`.
- `user` (string) Required, end-user identifier.
For file fields, upload local files with [`POST /files/upload`](#file-upload) first, then use the returned file `id` as `upload_file_id`. The `user` must be the same in both requests.
- `file-list` fields expect an array of file objects.
- `file` fields expect one file object.
- For each submitted file object, set `type` to one of the field's `allowed_file_types`: `image`, `document`, `audio`, or `video`.
When `remote_url` is allowed, you can submit a file URL directly:
<CodeGroup title="Remote URL file object" targetCode={`{
"type": "image",
"transfer_method": "remote_url",
"url": "https://example.com/image.png"
}`} />
### Response
Returns an empty object on success.
@ -1100,7 +1138,27 @@ Workflow applications offers non-session support and is ideal for translation, a
--header 'Authorization: Bearer {api_key}' \\
--header 'Content-Type: application/json' \\
--data-raw '{
"inputs": {"answer": "Approved answer"},
"inputs": {
"files": [
{
"type": "image",
"transfer_method": "local_file",
"upload_file_id": "{file_id_1}"
},
{
"type": "document",
"transfer_method": "local_file",
"upload_file_id": "{file_id_2}"
}
],
"a_single_file": {
"type": "image",
"transfer_method": "local_file",
"upload_file_id": "{file_id_3}"
},
"my_single_choice": "apple",
"my_paragraph": "hey welcome to Dify!"
},
"action": "approve",
"user": "abc-123"
}'`}

View File

@ -1005,7 +1005,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等
### Response
- `form_content` (string) 已渲染的表单内容markdown/plain text
- `inputs` (array[object]) 表单输入项定义
- `inputs` (array[object]) 表单输入项定义。支持的 `type` 包括 `paragraph`、`select`、`file` 和 `file-list`;各类型结构见示例。
- `resolved_default_values` (object) 已解析的默认值(字符串)
- `user_actions` (array[object]) 操作按钮列表
- `expiration_time` (timestamp) 表单过期时间Unix 秒)
@ -1027,18 +1027,43 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{
"form_content": "请确认最终结果:{{#$output.answer#}}",
"form_content": "Please upload a file list:\n{{#$output.files#}}\n\nPlease upload a single file:\n{{#$output.a_single_file#}}\n\nPlease select an option:\n{{#$output.my_single_choice#}}\n\nPlease enter a paragraph:\n{{#$output.my_paragraph#}}\n",
"inputs": [
{
"label": "答案",
"type": "text-input",
"required": true,
"output_variable_name": "answer"
"output_variable_name": "files",
"allowed_file_types": ["image", "document", "audio", "video"],
"allowed_file_extensions": [],
"allowed_file_upload_methods": ["local_file", "remote_url"],
"type": "file-list",
"number_limits": 5
},
{
"output_variable_name": "a_single_file",
"allowed_file_types": ["image", "document", "audio", "video"],
"allowed_file_extensions": [],
"allowed_file_upload_methods": ["local_file", "remote_url"],
"type": "file"
},
{
"output_variable_name": "my_single_choice",
"type": "select",
"option_source": {
"type": "constant",
"selector": [],
"value": ["apple", "orange", "strawberry"]
}
},
{
"output_variable_name": "my_paragraph",
"type": "paragraph",
"default": {
"type": "constant",
"selector": [],
"value": "this is a default value for my paragraph"
}
}
],
"resolved_default_values": {
"answer": "初始值"
},
"resolved_default_values": {},
"user_actions": [
{ "id": "approve", "title": "通过", "button_style": "primary" },
{ "id": "reject", "title": "拒绝", "button_style": "warning" }
@ -1070,6 +1095,19 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等
- `action` (string) 必填,从 `user_actions` 中选择的动作 ID
- `user` (string) 必填,终端用户标识
对于文件字段,请先通过 [`POST /files/upload`](#files-upload) 上传本地文件,然后使用返回的文件 `id` 作为 `upload_file_id`。两次请求中的 `user` 必须保持一致。
- `file-list` 字段提交文件对象数组。
- `file` 字段提交单个文件对象。
- 提交的每个文件对象都需要设置 `type`,其值必须来自该字段的 `allowed_file_types``image`、`document`、`audio` 或 `video`。
当允许 `remote_url` 时,也可以直接提交文件 URL
<CodeGroup title="远程 URL 文件对象" targetCode={`{
"type": "image",
"transfer_method": "remote_url",
"url": "https://example.com/image.png"
}`} />
### Response
成功时返回空对象。
@ -1088,7 +1126,27 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等
--header 'Authorization: Bearer {api_key}' \\
--header 'Content-Type: application/json' \\
--data-raw '{
"inputs": {"answer": "已确认答案"},
"inputs": {
"files": [
{
"type": "image",
"transfer_method": "local_file",
"upload_file_id": "{file_id_1}"
},
{
"type": "document",
"transfer_method": "local_file",
"upload_file_id": "{file_id_2}"
}
],
"a_single_file": {
"type": "image",
"transfer_method": "local_file",
"upload_file_id": "{file_id_3}"
},
"my_single_choice": "apple",
"my_paragraph": "hey welcome to Dify!"
},
"action": "approve",
"user": "abc-123"
}'`}