mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-09 10:56:52 +08:00
docs: improve api documentation for advanced chat and workflow (#9882)
This commit is contained in:
@@ -42,6 +42,7 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等
|
||||
- `inputs` (object) Required
|
||||
允许传入 App 定义的各变量值。
|
||||
inputs 参数包含了多组键值对(Key/Value pairs),每组的键对应一个特定变量,每组的值则是该变量的具体值。
|
||||
如果变量是文件类型,请指定一个包含以下 `files` 中所述键的对象。
|
||||
- `response_mode` (string) Required
|
||||
返回响应模式,支持:
|
||||
- `streaming` 流式模式(推荐)。基于 SSE(**[Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)**)实现类似打字机输出方式的流式返回。
|
||||
@@ -324,6 +325,79 @@ Workflow 应用无会话支持,适合用于翻译/文章写作/总结 AI 等
|
||||
|
||||
---
|
||||
|
||||
<Heading
|
||||
url='/files/upload'
|
||||
method='POST'
|
||||
title='上传文件'
|
||||
name='#files-upload'
|
||||
/>
|
||||
<Row>
|
||||
<Col>
|
||||
上传文件并在发送消息时使用,可实现图文多模态理解。
|
||||
支持您的工作流程所支持的任何格式。
|
||||
<i>上传的文件仅供当前终端用户使用。</i>
|
||||
|
||||
### Request Body
|
||||
该接口需使用 `multipart/form-data` 进行请求。
|
||||
<Properties>
|
||||
<Property name='file' type='file' key='file'>
|
||||
要上传的文件。
|
||||
</Property>
|
||||
<Property name='user' type='string' key='user'>
|
||||
用户标识,用于定义终端用户的身份,必须和发送消息接口传入 user 保持一致。
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
### Response
|
||||
成功上传后,服务器会返回文件的 ID 和相关信息。
|
||||
- `id` (uuid) ID
|
||||
- `name` (string) 文件名
|
||||
- `size` (int) 文件大小(byte)
|
||||
- `extension` (string) 文件后缀
|
||||
- `mime_type` (string) 文件 mime-type
|
||||
- `created_by` (uuid) 上传人 ID
|
||||
- `created_at` (timestamp) 上传时间
|
||||
|
||||
### Errors
|
||||
- 400,`no_file_uploaded`,必须提供文件
|
||||
- 400,`too_many_files`,目前只接受一个文件
|
||||
- 400,`unsupported_preview`,该文件不支持预览
|
||||
- 400,`unsupported_estimate`,该文件不支持估算
|
||||
- 413,`file_too_large`,文件太大
|
||||
- 415,`unsupported_file_type`,不支持的扩展名,当前只接受文档类文件
|
||||
- 503,`s3_connection_failed`,无法连接到 S3 服务
|
||||
- 503,`s3_permission_denied`,无权限上传文件到 S3
|
||||
- 503,`s3_file_too_large`,文件超出 S3 大小限制
|
||||
</Col>
|
||||
<Col sticky>
|
||||
|
||||
<CodeGroup title="Request" tag="POST" label="/files/upload" targetCode={`curl -X POST '${props.appDetail.api_base_url}/files/upload' \\\n--header 'Authorization: Bearer {api_key}' \\\n--form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif] \\\n--form 'user=abc-123'`}>
|
||||
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X POST '${props.appDetail.api_base_url}/files/upload' \
|
||||
--header 'Authorization: Bearer {api_key}' \
|
||||
--form 'file=@"/path/to/file"'
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
<CodeGroup title="Response">
|
||||
```json {{ title: 'Response' }}
|
||||
{
|
||||
"id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
|
||||
"name": "example.png",
|
||||
"size": 1024,
|
||||
"extension": "png",
|
||||
"mime_type": "image/png",
|
||||
"created_by": 123,
|
||||
"created_at": 1577836800,
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
</Col>
|
||||
</Row>
|
||||
---
|
||||
|
||||
<Heading
|
||||
url='/parameters'
|
||||
method='GET'
|
||||
|
||||
Reference in New Issue
Block a user