获取工作流的输入
在开始运行前读取工作流所需的输入。
工作流的输入是在 Studio 中编写的,当作者修改它们时也会随之变化。请读取契约,而不是把它硬编码。
GET {base_url}/workflows/{workflow_id}/inputs需要 workflows:read。
响应
{
"workflow": {
"id": "0192f3c3-9d21-7c44-b8e1-5a7f2c9d4e10",
"name": "Story visuals",
"version_id": "0192f3c4-1a02-7bb3-9f40-2c6e8d1a5b77",
"schema_hash": "9fdf032d5b1c4e88",
"credits_estimate": 1840,
"duration_seconds_estimate": 420
},
"inputs": [
{
"key": "story_document",
"accepts": "url",
"type": "document",
"required": true,
"allow_multiple": false,
"url_content_types": ["application/pdf", "text/plain", "text/markdown"],
"max_bytes": 104857600,
"title": "Story document",
"description": "The finished story to adapt"
},
{
"key": "tone",
"accepts": "value",
"type": "string",
"required": true,
"allow_multiple": false,
"allowed_values": ["thriller", "romance", "mythology"],
"allow_custom": false,
"default_value": "thriller",
"title": "Tone"
}
]
}工作流对象
| 字段 | 含义 |
|---|---|
version_id | 运行现在将执行的版本。将它在运行时传回,以锁定这一精确契约 |
schema_hash | 任何输入发生变化时也会变化。用于与你的缓存进行比较的唯一字段 |
credits_estimate | 该工作流的一次运行平均消耗的积分 |
duration_seconds_estimate | 端到端平均耗时 |
每个输入
| 字段 | 含义 |
|---|---|
key | 在运行的 inputs 对象中使用的名称 |
accepts | value 直接发送该值本身 · url 发送一个公开的 HTTPS 链接 · option 发送 options[].id 中的一个 |
type | string, number, boolean, image, video, audio 或者 document |
required | 必须存在,除非 default_value 已设置 |
allow_multiple | 为 true 时,该值可以是数组;为 false 时,将拒绝数组 |
allowed_values | 对于 accepts: value:唯一可接受的字符串,除非 allow_custom 为 true |
allow_custom | 为 false 时,超出 allowed_values 或者 options 的值将被拒绝 |
minimum, maximum | 包含边界,适用于 type: number |
default_value | 当省略该输入时,运行将使用的内容 |
url_content_types | 对于 accepts: url:该链接可提供的内容类型 |
max_bytes | 对于 accepts: url:此输入接受的最大文件大小 |
options | 对于 accepts: option:{ "id", "label" } 条目。请按原样回传 id;它不是 URL |
title, description | 面向人类编写,可安全显示在你自己的 UI 中 |
按 schema_hash 缓存契约,并在运行因 invalid_request 被拒绝时重新读取它。工作流的作者可以在你的两次运行之间添加一个必需输入。