tts models support (#2033)
Co-authored-by: luowei <glpat-EjySCyNjWiLqAED-YmwM> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: Yeuoly <45712896+Yeuoly@users.noreply.github.com>
This commit is contained in:
10
web/app/components/develop/secret-key/assets/pause.svg
Normal file
10
web/app/components/develop/secret-key/assets/pause.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_129_2189)">
|
||||
<path d="M10.6666 14V10M13.3333 14V10M18.6666 12C18.6666 15.6819 15.6819 18.6667 12 18.6667C8.31808 18.6667 5.33331 15.6819 5.33331 12C5.33331 8.3181 8.31808 5.33333 12 5.33333C15.6819 5.33333 18.6666 8.3181 18.6666 12Z" stroke="#155EEF" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_129_2189">
|
||||
<rect width="16" height="16" fill="white" transform="translate(4 4)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 580 B |
11
web/app/components/develop/secret-key/assets/play.svg
Normal file
11
web/app/components/develop/secret-key/assets/play.svg
Normal file
@@ -0,0 +1,11 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_129_107)">
|
||||
<path d="M7.99991 14.6666C11.6819 14.6666 14.6666 11.6819 14.6666 7.99998C14.6666 4.31808 11.6819 1.33331 7.99998 1.33331C4.31808 1.33331 1.33331 4.31808 1.33331 7.99998C1.33331 11.6819 4.31808 14.6666 7.99998 14.6666Z" stroke="#155EEF" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M6.66665 5.33331L10.6666 7.99998L6.66665 10.6666V5.33331Z" stroke="#155EEF" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_129_107">
|
||||
<rect width="16" height="16" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 703 B |
11
web/app/components/develop/secret-key/assets/stop.svg
Normal file
11
web/app/components/develop/secret-key/assets/stop.svg
Normal file
@@ -0,0 +1,11 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_129_107)">
|
||||
<path d="M7.99998 14.6666C11.6819 14.6666 14.6666 11.6819 14.6666 7.99998C14.6666 4.31808 11.6819 1.33331 7.99998 1.33331C4.31808 1.33331 1.33331 4.31808 1.33331 7.99998C1.33331 11.6819 4.31808 14.6666 7.99998 14.6666Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M6.66665 5.33331L10.6666 7.99998L6.66665 10.6666V5.33331Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_129_107">
|
||||
<rect width="16" height="16" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 703 B |
@@ -6,7 +6,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from
|
||||
The text generation application offers non-session support and is ideal for translation, article writing, summarization AI, and more.
|
||||
|
||||
<div>
|
||||
### Base URL
|
||||
### Base URL
|
||||
<CodeGroup title="Code" targetCode={props.appDetail.api_base_url}>
|
||||
```javascript
|
||||
```
|
||||
@@ -14,10 +14,10 @@ The text generation application offers non-session support and is ideal for tran
|
||||
|
||||
### Authentication
|
||||
|
||||
The Service API uses `API-Key` authentication.
|
||||
The Service API uses `API-Key` authentication.
|
||||
<i>**Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.**</i>
|
||||
|
||||
For all API requests, include your API Key in the `Authorization` HTTP Header, as shown below:
|
||||
For all API requests, include your API Key in the `Authorization` HTTP Header, as shown below:
|
||||
|
||||
<CodeGroup title="Code">
|
||||
```javascript
|
||||
@@ -46,18 +46,18 @@ The text generation application offers non-session support and is ideal for tran
|
||||
User Input/Question content
|
||||
</Property>
|
||||
<Property name='inputs' type='object' key='inputs'>
|
||||
Allows the entry of various variable values defined by the App.
|
||||
Allows the entry of various variable values defined by the App.
|
||||
The `inputs` parameter contains multiple key/value pairs, with each key corresponding to a specific variable and each value being the specific value for that variable.
|
||||
The text generation application requires at least one key/value pair to be inputted.
|
||||
</Property>
|
||||
<Property name='response_mode' type='string' key='response_mode'>
|
||||
The mode of response return, supporting:
|
||||
- `streaming` Streaming mode (recommended), implements a typewriter-like output through SSE ([Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)).
|
||||
- `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)
|
||||
- `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)
|
||||
<i>Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.</i>
|
||||
</Property>
|
||||
<Property name='user' type='string' key='user'>
|
||||
User identifier, used to define the identity of the end-user for retrieval and statistics.
|
||||
User identifier, used to define the identity of the end-user for retrieval and statistics.
|
||||
Should be uniquely defined by the developer within the application.
|
||||
</Property>
|
||||
<Property name='conversation_id' type='string' key='conversation_id'>
|
||||
@@ -71,9 +71,9 @@ The text generation application offers non-session support and is ideal for tran
|
||||
- `upload_file_id` (string) Uploaded file ID, which must be obtained by uploading through the File Upload API in advance (when the transfer method is `local_file`)
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
|
||||
### Response
|
||||
When `response_mode` is `blocking`, return a CompletionResponse object.
|
||||
When `response_mode` is `blocking`, return a CompletionResponse object.
|
||||
When `response_mode` is `streaming`, return a ChunkCompletionResponse stream.
|
||||
|
||||
### ChatCompletionResponse
|
||||
@@ -205,7 +205,7 @@ The text generation application offers non-session support and is ideal for tran
|
||||
<Row>
|
||||
<Col>
|
||||
Upload a file (currently only images are supported) for use when sending messages, enabling multimodal understanding of images and text.
|
||||
Supports png, jpg, jpeg, webp, gif formats.
|
||||
Supports png, jpg, jpeg, webp, gif formats.
|
||||
<i>Uploaded files are for use by the current end-user only.</i>
|
||||
|
||||
### Request Body
|
||||
@@ -214,7 +214,7 @@ The text generation application offers non-session support and is ideal for tran
|
||||
The file to be uploaded.
|
||||
- `user` (string) Required
|
||||
User identifier, defined by the developer's rules, must be unique within the application.
|
||||
|
||||
|
||||
### Response
|
||||
After a successful upload, the server will return the file's ID and related information.
|
||||
- `id` (uuid) ID
|
||||
@@ -236,7 +236,7 @@ The text generation application offers non-session support and is ideal for tran
|
||||
- 503, `s3_permission_denied`, no permission to upload files to S3
|
||||
- 503, `s3_file_too_large`, file exceeds S3 size limit
|
||||
- 500, internal server error
|
||||
|
||||
|
||||
|
||||
</Col>
|
||||
<Col sticky>
|
||||
@@ -256,12 +256,12 @@ The text generation application offers non-session support and is ideal for tran
|
||||
<CodeGroup title="Response">
|
||||
```json {{ title: 'Response' }}
|
||||
{
|
||||
"id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
|
||||
"id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
|
||||
"name": "example.png",
|
||||
"size": 1024,
|
||||
"extension": "png",
|
||||
"mime_type": "image/png",
|
||||
"created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",
|
||||
"created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",
|
||||
"created_at": 1577836800,
|
||||
}
|
||||
```
|
||||
@@ -292,8 +292,8 @@ The text generation application offers non-session support and is ideal for tran
|
||||
<CodeGroup title="Request" tag="POST" label="/chat-messages/:task_id/stop" targetCode={`curl -X POST 'https://cloud.dify.ai/v1/chat-messages/:task_id/stop' \\\n-H 'Authorization: Bearer {api_key}' \\\n-H 'Content-Type: application/json' \\\n--data-raw '{ "user": "abc-123"}`}>
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X POST 'https://cloud.dify.ai/v1/chat-messages/:task_id/stop' \
|
||||
-H 'Authorization: Bearer {api_key}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Bearer {api_key}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"user": "abc-123"
|
||||
}'
|
||||
@@ -484,3 +484,51 @@ The text generation application offers non-session support and is ideal for tran
|
||||
</CodeGroup>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
---
|
||||
|
||||
<Heading
|
||||
url='/text-to-audio'
|
||||
method='POST'
|
||||
title='text to audio'
|
||||
name='#audio'
|
||||
/>
|
||||
<Row>
|
||||
<Col>
|
||||
Text to speech, only supports openai model.
|
||||
|
||||
### Request Body
|
||||
|
||||
<Properties>
|
||||
<Property name='text' type='str' key='text'>
|
||||
Speech generated content。
|
||||
</Property>
|
||||
<Property name='user' type='string' key='user'>
|
||||
The user identifier, defined by the developer, must ensure uniqueness within the app.
|
||||
</Property>
|
||||
<Property name='streaming' type='bool' key='streaming'>
|
||||
Whether to enable streaming output, true、false。
|
||||
</Property>
|
||||
</Properties>
|
||||
</Col>
|
||||
<Col sticky>
|
||||
|
||||
<CodeGroup title="Request" tag="POST" label="/text-to-audio" targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \\\n--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\\n--form 'text=Hello Dify;user=abc-123;streaming=false`}>
|
||||
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \
|
||||
--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
|
||||
--form 'file=Hello Dify;user=abc-123;streaming=false'
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
<CodeGroup title="headers">
|
||||
```json {{ title: 'headers' }}
|
||||
{
|
||||
"Content-Type": "audio/wav"
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
</Col>
|
||||
</Row>
|
@@ -14,9 +14,9 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
|
||||
### 鉴权
|
||||
|
||||
|
||||
Dify Service API 使用 `API-Key` 进行鉴权。
|
||||
<i>**强烈建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。**</i>
|
||||
|
||||
Dify Service API 使用 `API-Key` 进行鉴权。
|
||||
<i>**强烈建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。**</i>
|
||||
所有 API 请求都应在 **`Authorization`** HTTP Header 中包含您的 `API-Key`,如下所示:
|
||||
|
||||
<CodeGroup title="Code">
|
||||
@@ -46,16 +46,16 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
</Property>
|
||||
<Property name='inputs' type='object' key='inputs'>
|
||||
(选填)允许传入 App 定义的各变量值。
|
||||
inputs 参数包含了多组键值对(Key/Value pairs),每组的键对应一个特定变量,每组的值则是该变量的具体值。
|
||||
inputs 参数包含了多组键值对(Key/Value pairs),每组的键对应一个特定变量,每组的值则是该变量的具体值。
|
||||
文本生成型应用要求至少传入一组键值对。
|
||||
</Property>
|
||||
<Property name='response_mode' type='string' key='response_mode'>
|
||||
- `streaming` 流式模式(推荐)。基于 SSE(**[Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)**)实现类似打字机输出方式的流式返回。
|
||||
- `blocking` 阻塞模式,等待执行完毕后返回结果。(请求若流程较长可能会被中断)。
|
||||
- `blocking` 阻塞模式,等待执行完毕后返回结果。(请求若流程较长可能会被中断)。
|
||||
<i>由于 Cloudflare 限制,请求会在 100 秒超时无返回后中断。</i>
|
||||
</Property>
|
||||
<Property name='user' type='string' key='user'>
|
||||
用户标识,用于定义终端用户的身份,方便检索、统计。
|
||||
用户标识,用于定义终端用户的身份,方便检索、统计。
|
||||
由开发者定义规则,需保证用户标识在应用内唯一。
|
||||
</Property>
|
||||
<Property name='conversation_id' type='string' key='conversation_id'>
|
||||
@@ -74,9 +74,9 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
|
||||
### Response
|
||||
<Properties>
|
||||
当 `response_mode` 为 `blocking` 时,返回 ChatCompletionResponse object。
|
||||
当 `response_mode` 为 `blocking` 时,返回 ChatCompletionResponse object。
|
||||
当 `response_mode` 为 `streaming`时,返回 ChunkChatCompletionResponse object 流式序列。
|
||||
|
||||
|
||||
### ChatCompletionResponse
|
||||
返回完整的 App 结果,`Content-Type` 为 `application/json`。
|
||||
- `message_id` (string) 消息唯一 ID
|
||||
@@ -184,7 +184,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
<Row>
|
||||
<Col>
|
||||
上传文件(目前仅支持图片)并在发送消息时使用,可实现图文多模态理解。
|
||||
支持 png, jpg, jpeg, webp, gif 格式。
|
||||
支持 png, jpg, jpeg, webp, gif 格式。
|
||||
<i>上传的文件仅供当前终端用户使用。</i>
|
||||
|
||||
### Request Body
|
||||
@@ -234,12 +234,12 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
<CodeGroup title="Response">
|
||||
```json {{ title: 'Response' }}
|
||||
{
|
||||
"id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
|
||||
"id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
|
||||
"name": "example.png",
|
||||
"size": 1024,
|
||||
"extension": "png",
|
||||
"mime_type": "image/png",
|
||||
"created_by": 123,
|
||||
"created_by": 123,
|
||||
"created_at": 1577836800,
|
||||
}
|
||||
```
|
||||
@@ -258,7 +258,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
仅支持流式模式。
|
||||
### Path
|
||||
- `task_id` (string) 任务 ID,可在流式返回 Chunk 中获取
|
||||
|
||||
|
||||
### Request Body
|
||||
- `user` (string) Required
|
||||
用户标识,用于定义终端用户的身份,必须和发送消息接口传入 user 保持一致。
|
||||
@@ -378,7 +378,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
- `annotation_reply` (object) 标记回复
|
||||
- `enabled` (bool) 是否开启
|
||||
- `user_input_form` (array[object]) 用户输入表单配置
|
||||
- `text-input` (object) 文本输入控件
|
||||
- `text-input` (object) 文本输入控件
|
||||
- `label` (string) 控件展示标签名
|
||||
- `variable` (string) 控件 ID
|
||||
- `required` (bool) 是否必填
|
||||
@@ -388,7 +388,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
- `variable` (string) 控件 ID
|
||||
- `required` (bool) 是否必填
|
||||
- `default` (string) 默认值
|
||||
- `select` (object) 下拉控件
|
||||
- `select` (object) 下拉控件
|
||||
- `label` (string) 控件展示标签名
|
||||
- `variable` (string) 控件 ID
|
||||
- `required` (bool) 是否必填
|
||||
@@ -447,3 +447,51 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
</CodeGroup>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
---
|
||||
|
||||
<Heading
|
||||
url='/text-to-audio'
|
||||
method='POST'
|
||||
title='文字转语音'
|
||||
name='#audio'
|
||||
/>
|
||||
<Row>
|
||||
<Col>
|
||||
文字转语音,仅支持 openai 模型。
|
||||
|
||||
### Request Body
|
||||
|
||||
<Properties>
|
||||
<Property name='text' type='str' key='text'>
|
||||
语音生成内容。
|
||||
</Property>
|
||||
<Property name='user' type='string' key='user'>
|
||||
用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
|
||||
</Property>
|
||||
<Property name='streaming' type='bool' key='streaming'>
|
||||
是否启用流式输出true、false。
|
||||
</Property>
|
||||
</Properties>
|
||||
</Col>
|
||||
<Col sticky>
|
||||
|
||||
<CodeGroup title="Request" tag="POST" label="/text-to-audio" targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \\\n--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\\n--form 'text=你好Dify;user=abc-123;streaming=false`}>
|
||||
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \
|
||||
--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
|
||||
--form 'file=你好Dify;user=abc-123;streaming=false'
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
<CodeGroup title="headers">
|
||||
```json {{ title: 'headers' }}
|
||||
{
|
||||
"Content-Type": "audio/wav"
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
</Col>
|
||||
</Row>
|
||||
|
@@ -6,7 +6,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty, Paragraph } from
|
||||
Chat applications support session persistence, allowing previous chat history to be used as context for responses. This can be applicable for chatbots, customer service AI, etc.
|
||||
|
||||
<div>
|
||||
### Base URL
|
||||
### Base URL
|
||||
<CodeGroup title="Code" targetCode={props.appDetail.api_base_url}>
|
||||
```javascript
|
||||
```
|
||||
@@ -14,10 +14,10 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
|
||||
### Authentication
|
||||
|
||||
The Service API uses `API-Key` authentication.
|
||||
The Service API uses `API-Key` authentication.
|
||||
<i>**Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.**</i>
|
||||
|
||||
For all API requests, include your API Key in the `Authorization`HTTP Header, as shown below:
|
||||
For all API requests, include your API Key in the `Authorization`HTTP Header, as shown below:
|
||||
|
||||
<CodeGroup title="Code">
|
||||
```javascript
|
||||
@@ -46,18 +46,18 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
User Input/Question content
|
||||
</Property>
|
||||
<Property name='inputs' type='object' key='inputs'>
|
||||
Allows the entry of various variable values defined by the App.
|
||||
Allows the entry of various variable values defined by the App.
|
||||
The `inputs` parameter contains multiple key/value pairs, with each key corresponding to a specific variable and each value being the specific value for that variable.
|
||||
</Property>
|
||||
<Property name='response_mode' type='string' key='response_mode'>
|
||||
The mode of response return, supporting:
|
||||
- `streaming` Streaming mode (recommended), implements a typewriter-like output through SSE ([Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)).
|
||||
- `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)
|
||||
Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.
|
||||
- `blocking` Blocking mode, returns result after execution is complete. (Requests may be interrupted if the process is long)
|
||||
Due to Cloudflare restrictions, the request will be interrupted without a return after 100 seconds.
|
||||
<i>Note: blocking mode is not supported in Agent Assistant mode</i>
|
||||
</Property>
|
||||
<Property name='user' type='string' key='user'>
|
||||
User identifier, used to define the identity of the end-user for retrieval and statistics.
|
||||
User identifier, used to define the identity of the end-user for retrieval and statistics.
|
||||
Should be uniquely defined by the developer within the application.
|
||||
</Property>
|
||||
<Property name='conversation_id' type='string' key='conversation_id'>
|
||||
@@ -75,9 +75,9 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
Can achieve async title generation by calling the conversation rename API and setting `auto_generate` to true.
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
|
||||
### Response
|
||||
When response_mode is blocking, return a CompletionResponse object.
|
||||
When response_mode is blocking, return a CompletionResponse object.
|
||||
When response_mode is streaming, return a ChunkCompletionResponse stream.
|
||||
|
||||
### ChatCompletionResponse
|
||||
@@ -122,7 +122,7 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
- `tool` (string) A list of tools represents which tools are called,split by ;
|
||||
- `tool_input` (string) Input of tools in JSON format. Like: `{"dalle3": {"prompt": "a cute cat"}}`.
|
||||
- `created_at` (int) Creation timestamp, e.g., 1705395332
|
||||
- `message_files` (array[string]) Refer to message_file event
|
||||
- `message_files` (array[string]) Refer to message_file event
|
||||
- `file_id` (string) File ID
|
||||
- `conversation_id` (string) Conversation ID
|
||||
- `event: message_file` Message file event, a new file has created by tool
|
||||
@@ -260,7 +260,7 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
<Row>
|
||||
<Col>
|
||||
Upload a file (currently only images are supported) for use when sending messages, enabling multimodal understanding of images and text.
|
||||
Supports png, jpg, jpeg, webp, gif formats.
|
||||
Supports png, jpg, jpeg, webp, gif formats.
|
||||
Uploaded files are for use by the current end-user only.
|
||||
|
||||
### Request Body
|
||||
@@ -269,7 +269,7 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
The file to be uploaded.
|
||||
- `user` (string) Required
|
||||
User identifier, defined by the developer's rules, must be unique within the application.
|
||||
|
||||
|
||||
### Response
|
||||
After a successful upload, the server will return the file's ID and related information.
|
||||
- `id` (uuid) ID
|
||||
@@ -291,7 +291,7 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
- 503, `s3_permission_denied`, no permission to upload files to S3
|
||||
- 503, `s3_file_too_large`, file exceeds S3 size limit
|
||||
- 500, internal server error
|
||||
|
||||
|
||||
|
||||
</Col>
|
||||
<Col sticky>
|
||||
@@ -311,12 +311,12 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
<CodeGroup title="Response">
|
||||
```json {{ title: 'Response' }}
|
||||
{
|
||||
"id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
|
||||
"id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
|
||||
"name": "example.png",
|
||||
"size": 1024,
|
||||
"extension": "png",
|
||||
"mime_type": "image/png",
|
||||
"created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",
|
||||
"created_by": "6ad1ab0a-73ff-4ac1-b9e4-cdb312f71f13",
|
||||
"created_at": 1577836800,
|
||||
}
|
||||
```
|
||||
@@ -347,8 +347,8 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
<CodeGroup title="Request" tag="POST" label="/chat-messages/:task_id/stop" targetCode={`curl -X POST 'https://cloud.dify.ai/v1/chat-messages/:task_id/stop' \\\n-H 'Authorization: Bearer {api_key}' \\\n-H 'Content-Type: application/json' \\\n--data-raw '{ "user": "abc-123"}`}>
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X POST 'https://cloud.dify.ai/v1/chat-messages/:task_id/stop' \
|
||||
-H 'Authorization: Bearer {api_key}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Bearer {api_key}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"user": "abc-123"
|
||||
}'
|
||||
@@ -444,7 +444,7 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
Conversation ID
|
||||
</Property>
|
||||
<Property name='user' type='string' key='user'>
|
||||
User identifier, used to define the identity of the end-user for retrieval and statistics.
|
||||
User identifier, used to define the identity of the end-user for retrieval and statistics.
|
||||
Should be uniquely defined by the developer within the application.
|
||||
</Property>
|
||||
<Property name='first_id' type='string' key='first_id'>
|
||||
@@ -475,7 +475,7 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
- `tool` (string) A list of tools represents which tools are called,split by ;
|
||||
- `tool_input` (string) Input of tools in JSON format. Like: `{"dalle3": {"prompt": "a cute cat"}}`.
|
||||
- `created_at` (int) Creation timestamp, e.g., 1705395332
|
||||
- `message_files` (array[string]) Refer to message_file event
|
||||
- `message_files` (array[string]) Refer to message_file event
|
||||
- `file_id` (string) File ID
|
||||
- `answer` (string) Response message content
|
||||
- `created_at` (timestamp) Creation timestamp, e.g., 1705395332
|
||||
@@ -609,7 +609,7 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
|
||||
<Properties>
|
||||
<Property name='user' type='string' key='user'>
|
||||
User identifier, used to define the identity of the end-user for retrieval and statistics.
|
||||
User identifier, used to define the identity of the end-user for retrieval and statistics.
|
||||
Should be uniquely defined by the developer within the application.
|
||||
</Property>
|
||||
<Property name='last_id' type='string' key='last_id'>
|
||||
@@ -800,8 +800,8 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
|
||||
<Properties>
|
||||
<Property name='file' type='file' key='file'>
|
||||
Audio file.
|
||||
Supported formats: `['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`
|
||||
Audio file.
|
||||
Supported formats: `['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`
|
||||
File size limit: 15MB
|
||||
</Property>
|
||||
<Property name='user' type='string' key='user'>
|
||||
@@ -837,6 +837,54 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
|
||||
---
|
||||
|
||||
<Heading
|
||||
url='/text-to-audio'
|
||||
method='POST'
|
||||
title='text to audio'
|
||||
name='#audio'
|
||||
/>
|
||||
<Row>
|
||||
<Col>
|
||||
Text to speech, only supports openai model.
|
||||
|
||||
### Request Body
|
||||
|
||||
<Properties>
|
||||
<Property name='text' type='str' key='text'>
|
||||
Speech generated content。
|
||||
</Property>
|
||||
<Property name='user' type='string' key='user'>
|
||||
The user identifier, defined by the developer, must ensure uniqueness within the app.
|
||||
</Property>
|
||||
<Property name='streaming' type='bool' key='streaming'>
|
||||
Whether to enable streaming output, true、false。
|
||||
</Property>
|
||||
</Properties>
|
||||
</Col>
|
||||
<Col sticky>
|
||||
|
||||
<CodeGroup title="Request" tag="POST" label="/text-to-audio" targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \\\n--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\\n--form 'text=Hello Dify;user=abc-123;streaming=false`}>
|
||||
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \
|
||||
--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
|
||||
--form 'file=Hello Dify;user=abc-123;streaming=false'
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
<CodeGroup title="headers">
|
||||
```json {{ title: 'headers' }}
|
||||
{
|
||||
"Content-Type": "audio/wav"
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
---
|
||||
|
||||
<Heading
|
||||
url='/parameters'
|
||||
method='GET'
|
||||
@@ -969,7 +1017,7 @@ Chat applications support session persistence, allowing previous chat history to
|
||||
</Properties>
|
||||
### Response
|
||||
- `tool_icons`(object[string]) tool icons
|
||||
- `tool_name` (string)
|
||||
- `tool_name` (string)
|
||||
- `icon` (object|string)
|
||||
- (object) icon object
|
||||
- `background` (string) background color in hex format
|
||||
|
@@ -14,8 +14,8 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
|
||||
### 鉴权
|
||||
|
||||
Service API 使用 `API-Key` 进行鉴权。
|
||||
<i>**强烈建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。**</i>
|
||||
Service API 使用 `API-Key` 进行鉴权。
|
||||
<i>**强烈建议开发者把 `API-Key` 放在后端存储,而非分享或者放在客户端存储,以免 `API-Key` 泄露,导致财产损失。**</i>
|
||||
所有 API 请求都应在 **`Authorization`** HTTP Header 中包含您的 `API-Key`,如下所示:
|
||||
|
||||
<CodeGroup title="Code">
|
||||
@@ -44,14 +44,14 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
用户输入/提问内容。
|
||||
</Property>
|
||||
<Property name='inputs' type='object' key='inputs'>
|
||||
(选填)允许传入 App 定义的各变量值。
|
||||
(选填)允许传入 App 定义的各变量值。
|
||||
inputs 参数包含了多组键值对(Key/Value pairs),每组的键对应一个特定变量,每组的值则是该变量的具体值。
|
||||
|
||||
</Property>
|
||||
<Property name='response_mode' type='string' key='response_mode'>
|
||||
- `streaming` 流式模式(推荐)。基于 SSE(**[Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)**)实现类似打字机输出方式的流式返回。
|
||||
- `blocking` 阻塞模式,等待执行完毕后返回结果。(请求若流程较长可能会被中断)。
|
||||
<i>由于 Cloudflare 限制,请求会在 100 秒超时无返回后中断。</i>
|
||||
- `blocking` 阻塞模式,等待执行完毕后返回结果。(请求若流程较长可能会被中断)。
|
||||
<i>由于 Cloudflare 限制,请求会在 100 秒超时无返回后中断。</i>
|
||||
注:Agent模式下不允许blocking。
|
||||
</Property>
|
||||
<Property name='user' type='string' key='user'>
|
||||
@@ -77,9 +77,9 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
|
||||
### Response
|
||||
<Properties>
|
||||
当 `response_mode` 为 `blocking` 时,返回 ChatCompletionResponse object。
|
||||
当 `response_mode` 为 `blocking` 时,返回 ChatCompletionResponse object。
|
||||
当 `response_mode` 为 `streaming`时,返回 ChunkChatCompletionResponse object 流式序列。
|
||||
|
||||
|
||||
### ChatCompletionResponse
|
||||
|
||||
返回完整的 App 结果,`Content-Type` 为 `application/json`。
|
||||
@@ -147,7 +147,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
- `conversation_id` (string) 会话 ID
|
||||
- `answer` (string) 替换内容(直接替换 LLM 所有回复文本)
|
||||
- `created_at` (int) 创建时间戳,如:1705395332
|
||||
- `event: error`
|
||||
- `event: error`
|
||||
流式输出过程中出现的异常会以 stream event 形式输出,收到异常事件后即结束。
|
||||
- `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口
|
||||
- `message_id` (string) 消息唯一 ID
|
||||
@@ -278,7 +278,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
<Row>
|
||||
<Col>
|
||||
上传文件(目前仅支持图片)并在发送消息时使用,可实现图文多模态理解。
|
||||
支持 png, jpg, jpeg, webp, gif 格式。
|
||||
支持 png, jpg, jpeg, webp, gif 格式。
|
||||
<i>上传的文件仅供当前终端用户使用。</i>
|
||||
|
||||
### Request Body
|
||||
@@ -328,12 +328,12 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
<CodeGroup title="Response">
|
||||
```json {{ title: 'Response' }}
|
||||
{
|
||||
"id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
|
||||
"id": "72fa9618-8f89-4a37-9b33-7e1178a24a67",
|
||||
"name": "example.png",
|
||||
"size": 1024,
|
||||
"extension": "png",
|
||||
"mime_type": "image/png",
|
||||
"created_by": 123,
|
||||
"created_by": 123,
|
||||
"created_at": 1577836800,
|
||||
}
|
||||
```
|
||||
@@ -352,7 +352,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
仅支持流式模式。
|
||||
### Path
|
||||
- `task_id` (string) 任务 ID,可在流式返回 Chunk 中获取
|
||||
|
||||
|
||||
### Request Body
|
||||
- `user` (string) Required
|
||||
用户标识,用于定义终端用户的身份,必须和发送消息接口传入 user 保持一致。
|
||||
@@ -772,7 +772,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
</Properties>
|
||||
|
||||
### Response
|
||||
- `result` (string) 固定返回 success
|
||||
- `result` (string) 固定返回 success
|
||||
</Col>
|
||||
<Col sticky>
|
||||
|
||||
@@ -874,7 +874,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
<Properties>
|
||||
<Property name='file' type='file' key='file'>
|
||||
语音文件。
|
||||
支持格式:`['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`
|
||||
支持格式:`['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']`
|
||||
文件大小限制:15MB
|
||||
</Property>
|
||||
<Property name='user' type='string' key='user'>
|
||||
@@ -909,6 +909,54 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
|
||||
---
|
||||
|
||||
<Heading
|
||||
url='/text-to-audio'
|
||||
method='POST'
|
||||
title='文字转语音'
|
||||
name='#audio'
|
||||
/>
|
||||
<Row>
|
||||
<Col>
|
||||
文字转语音,仅支持 openai 模型。
|
||||
|
||||
### Request Body
|
||||
|
||||
<Properties>
|
||||
<Property name='text' type='str' key='text'>
|
||||
语音生成内容。
|
||||
</Property>
|
||||
<Property name='user' type='string' key='user'>
|
||||
用户标识,由开发者定义规则,需保证用户标识在应用内唯一。
|
||||
</Property>
|
||||
<Property name='streaming' type='bool' key='streaming'>
|
||||
是否启用流式输出true、false。
|
||||
</Property>
|
||||
</Properties>
|
||||
</Col>
|
||||
<Col sticky>
|
||||
|
||||
<CodeGroup title="Request" tag="POST" label="/text-to-audio" targetCode={`curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \\\n--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\\n--form 'text=你好Dify;user=abc-123;streaming=false`}>
|
||||
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl --location --request POST '${props.appDetail.api_base_url}/text-to-audio' \
|
||||
--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
|
||||
--form 'file=你好Dify;user=abc-123;streaming=false'
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
<CodeGroup title="headers">
|
||||
```json {{ title: 'headers' }}
|
||||
{
|
||||
"Content-Type": "audio/wav"
|
||||
}
|
||||
```
|
||||
</CodeGroup>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
---
|
||||
|
||||
<Heading
|
||||
url='/parameters'
|
||||
method='GET'
|
||||
@@ -939,7 +987,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
- `annotation_reply` (object) 标记回复
|
||||
- `enabled` (bool) 是否开启
|
||||
- `user_input_form` (array[object]) 用户输入表单配置
|
||||
- `text-input` (object) 文本输入控件
|
||||
- `text-input` (object) 文本输入控件
|
||||
- `label` (string) 控件展示标签名
|
||||
- `variable` (string) 控件 ID
|
||||
- `required` (bool) 是否必填
|
||||
@@ -949,7 +997,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
- `variable` (string) 控件 ID
|
||||
- `required` (bool) 是否必填
|
||||
- `default` (string) 默认值
|
||||
- `select` (object) 下拉控件
|
||||
- `select` (object) 下拉控件
|
||||
- `label` (string) 控件展示标签名
|
||||
- `variable` (string) 控件 ID
|
||||
- `required` (bool) 是否必填
|
||||
@@ -1029,7 +1077,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
|
||||
</Properties>
|
||||
### Response
|
||||
- `tool_icons`(object[string]) 工具图标
|
||||
- `工具名称` (string)
|
||||
- `工具名称` (string)
|
||||
- `icon` (object|string)
|
||||
- (object) 图标
|
||||
- `background` (string) hex格式的背景色
|
||||
|
Reference in New Issue
Block a user