| | |
| | | ### Request Body |
| | | - `inputs` (object) Required |
| | | 允许传入 App 定义的各变量值。 |
| | | inputs 参数包含了多组键值对(Key/Value pairs),每组的键对应一个特定变量,每组的值则是该变量的具体值。变量可以是文件列表类型。 |
| | | 文件列表类型变量适用于传入文件结合文本理解并回答问题,仅当模型支持该类型文件解析能力时可用。如果该变量是文件列表类型,该变量对应的值应是列表格式,其中每个元素应包含以下内容: |
| | | - `type` (string) 支持类型: |
| | | - `document` 具体类型包含:'TXT', 'MD', 'MARKDOWN', 'PDF', 'HTML', 'XLSX', 'XLS', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB' |
| | | - `image` 具体类型包含:'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG' |
| | | - `audio` 具体类型包含:'MP3', 'M4A', 'WAV', 'WEBM', 'AMR' |
| | | - `video` 具体类型包含:'MP4', 'MOV', 'MPEG', 'MPGA' |
| | | - `custom` 具体类型包含:其他文件类型 |
| | | - `transfer_method` (string) 传递方式,`remote_url` 图片地址 / `local_file` 上传文件 |
| | | - `url` (string) 图片地址(仅当传递方式为 `remote_url` 时) |
| | | - `upload_file_id` (string) 上传文件 ID(仅当传递方式为 `local_file` 时) |
| | | 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)**)实现类似打字机输出方式的流式返回。 |
| | |
| | | - `user` (string) Required |
| | | 用户标识,用于定义终端用户的身份,方便检索、统计。 |
| | | 由开发者定义规则,需保证用户标识在应用内唯一。 |
| | | |
| | | - `files` (array[object]) Optional |
| | | 文件列表,适用于传入文件结合文本理解并回答问题,仅当模型支持该类型文件解析能力时可用。 |
| | | - `type` (string) 支持类型: |
| | | - `document` 具体类型包含:'TXT', 'MD', 'MARKDOWN', 'PDF', 'HTML', 'XLSX', 'XLS', 'DOCX', 'CSV', 'EML', 'MSG', 'PPTX', 'PPT', 'XML', 'EPUB' |
| | | - `image` 具体类型包含:'JPG', 'JPEG', 'PNG', 'GIF', 'WEBP', 'SVG' |
| | | - `audio` 具体类型包含:'MP3', 'M4A', 'WAV', 'WEBM', 'AMR' |
| | | - `video` 具体类型包含:'MP4', 'MOV', 'MPEG', 'MPGA' |
| | | - `custom` 具体类型包含:其他文件类型 |
| | | - `transfer_method` (string) 传递方式,`remote_url` 图片地址 / `local_file` 上传文件 |
| | | - `url` (string) 图片地址(仅当传递方式为 `remote_url` 时) |
| | | - `upload_file_id` (string) (string) 上传文件 ID(仅当传递方式为 `local_file` 时) |
| | | |
| | | ### Response |
| | | 当 `response_mode` 为 `blocking` 时,返回 CompletionResponse object。 |
| | |
| | | 每个流式块均为 data: 开头,块之间以 `\n\n` 即两个换行符分隔,如下所示: |
| | | <CodeGroup> |
| | | ```streaming {{ title: 'Response' }} |
| | | data: {"event": "text_chunk", "workflow_run_id": "b85e5fc5-751b-454d-b14e-dc5f240b0a31", "task_id": "bd029338-b068-4d34-a331-fc85478922c2", "data": {"text": "\u4e3a\u4e86", "from_variable_selector": ["1745912968134", "text"]}}\n\n |
| | | data: {"event": "message", "task_id": "900bbd43-dc0b-4383-a372-aa6e6c414227", "id": "663c5084-a254-4040-8ad3-51f2a3c1a77c", "answer": "Hi", "created_at": 1705398420}\n\n |
| | | ``` |
| | | </CodeGroup> |
| | | 流式块中根据 `event` 不同,结构也不同,包含以下类型: |
| | |
| | | - `predecessor_node_id` (string) 前置节点 ID,用于画布展示执行路径 |
| | | - `inputs` (object) 节点中所有使用到的前置节点变量内容 |
| | | - `created_at` (timestamp) 开始时间 |
| | | - `event: text_chunk` 文本片段 |
| | | - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口 |
| | | - `workflow_run_id` (string) workflow 执行 ID |
| | | - `event` (string) 固定为 `text_chunk` |
| | | - `data` (object) 详细内容 |
| | | - `text` (string) 文本内容 |
| | | - `from_variable_selector` (array) 文本来源路径,帮助开发者了解文本是由哪个节点的哪个变量生成的 |
| | | - `event: node_finished` node 执行结束,成功失败同一事件中不同状态 |
| | | - `task_id` (string) 任务 ID,用于请求跟踪和下方的停止响应接口 |
| | | - `workflow_run_id` (string) workflow 执行 ID |
| | |
| | | }' |
| | | ``` |
| | | </CodeGroup> |
| | | <CodeGroup title="Example: file array as an input variable"> |
| | | <CodeGroup title="File variable example"> |
| | | ```json {{ title: 'File variable example' }} |
| | | { |
| | | "inputs": { |
| | | "{variable_name}": |
| | | [ |
| | | { |
| | | "{variable_name}": { |
| | | "transfer_method": "local_file", |
| | | "upload_file_id": "{upload_file_id}", |
| | | "type": "{document_type}" |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | ``` |
| | |
| | | |
| | | data = { |
| | | "inputs": { |
| | | "orig_mail": [{ |
| | | "orig_mail": { |
| | | "transfer_method": "local_file", |
| | | "upload_file_id": file_id, |
| | | "type": "document" |
| | | }] |
| | | } |
| | | }, |
| | | "response_mode": response_mode, |
| | | "user": user |
| | |
| | | --- |
| | | |
| | | <Heading |
| | | url='/workflows/run/:workflow_run_id' |
| | | url='/workflows/run/:workflow_id' |
| | | method='GET' |
| | | title='获取workflow执行情况' |
| | | name='#get-workflow-run-detail' |
| | |
| | | <Col> |
| | | 根据 workflow 执行 ID 获取 workflow 任务当前执行结果 |
| | | ### Path |
| | | - `workflow_run_id` (string) workflow_run_id,可在流式返回 Chunk 中获取 |
| | | - `workflow_id` (string) workflow 执行 ID,可在流式返回 Chunk 中获取 |
| | | ### Response |
| | | - `id` (string) workflow 执行 ID |
| | | - `workflow_id` (string) 关联的 Workflow ID |
| | |
| | | </Col> |
| | | <Col sticky> |
| | | ### Request Example |
| | | <CodeGroup title="Request" tag="GET" label="/workflows/run/:workflow_run_id" targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id' \\\n-H 'Authorization: Bearer {api_key}' \\\n-H 'Content-Type: application/json'`}> |
| | | <CodeGroup title="Request" tag="GET" label="/workflows/run/:workflow_id" targetCode={`curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_id' \\\n-H 'Authorization: Bearer {api_key}' \\\n-H 'Content-Type: application/json'`}> |
| | | ```bash {{ title: 'cURL' }} |
| | | curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_run_id' \ |
| | | curl -X GET '${props.appDetail.api_base_url}/workflows/run/:workflow_id' \ |
| | | -H 'Authorization: Bearer {api_key}' \ |
| | | -H 'Content-Type: application/json' |
| | | ``` |
| | |
| | | "error": null, |
| | | "total_steps": 3, |
| | | "total_tokens": 0, |
| | | "created_at": 1705407629, |
| | | "finished_at": 1727807631, |
| | | "created_at": "Thu, 18 Jul 2024 03:17:40 -0000", |
| | | "finished_at": "Thu, 18 Jul 2024 03:18:10 -0000", |
| | | "elapsed_time": 30.098514399956912 |
| | | } |
| | | ``` |
| | |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | |
| | | --- |
| | | |
| | | <Heading |
| | | url='/site' |
| | | method='GET' |
| | | title='获取应用 WebApp 设置' |
| | | name='#site' |
| | | /> |
| | | <Row> |
| | | <Col> |
| | | 用于获取应用的 WebApp 设置 |
| | | ### Response |
| | | - `title` (string) WebApp 名称 |
| | | - `icon_type` (string) 图标类型, `emoji`-表情, `image`-图片 |
| | | - `icon` (string) 图标, 如果是 `emoji` 类型, 则是 emoji 表情符号, 如果是 `image` 类型, 则是图片 URL |
| | | - `icon_background` (string) hex 格式的背景色 |
| | | - `icon_url` (string) 图标 URL |
| | | - `description` (string) 描述 |
| | | - `copyright` (string) 版权信息 |
| | | - `privacy_policy` (string) 隐私政策链接 |
| | | - `custom_disclaimer` (string) 自定义免责声明 |
| | | - `default_language` (string) 默认语言 |
| | | - `show_workflow_steps` (bool) 是否显示工作流详情 |
| | | </Col> |
| | | <Col> |
| | | <CodeGroup title="Request" tag="POST" label="/meta" targetCode={`curl -X GET '${props.appDetail.api_base_url}/site' \\\n-H 'Authorization: Bearer {api_key}'`}> |
| | | ```bash {{ title: 'cURL' }} |
| | | curl -X GET '${props.appDetail.api_base_url}/site' \ |
| | | -H 'Authorization: Bearer {api_key}' |
| | | ``` |
| | | |
| | | </CodeGroup> |
| | | |
| | | <CodeGroup title="Response"> |
| | | ```json {{ title: 'Response' }} |
| | | { |
| | | "title": "My App", |
| | | "icon_type": "emoji", |
| | | "icon": "😄", |
| | | "icon_background": "#FFEAD5", |
| | | "icon_url": null, |
| | | "description": "This is my app.", |
| | | "copyright": "all rights reserved", |
| | | "privacy_policy": "", |
| | | "custom_disclaimer": "All generated by AI", |
| | | "default_language": "en-US", |
| | | "show_workflow_steps": false, |
| | | } |
| | | ``` |
| | | </CodeGroup> |
| | | </Col> |
| | | </Row> |
| | | ___ |