决策
针对一段文本、数据或图像的具名问题,给出类型化的答案
Decisions 模型读取 state,并以固定的答案类型回答你命名的每个问题。可用于工单分流、内容评级、是非判断和评分。Decisions 模型仅按输入 token 计费,没有输出价格。当前价格请参阅服务。
| 模型 | 输入 |
|---|---|
gemini-decision-1 | 文本、图像、音频、视频和文件 |
gpt-6-luna-decisions | 文本和图像 |
typesafe-jev-1.14 | 文本和图像 |
请求
将 POST 请求发送到 /v1/decisions,并在 Authorization 请求头中附上你的 API 密钥。
| 字段 | 类型 | 说明 |
|---|---|---|
model | string | 一个 Decisions 决策模型。如果不指定,默认使用 gemini-decision-1 模型。 |
state | 字符串、对象或数组 | 必填。问题所针对的文本、数据或媒体。图像以 image_url 部分放在数组中。 |
questions | object | 1 至 50 个问题,每个问题有自己的名称,由 1 至 64 个字母、数字、下划线或连字符组成。除非发送 options,否则必填。 |
options | array | 可选。2 至 255 个待排序的选项,可以是文本,也可以是带 value 和 description 的对象。请参阅选项排序。 |
instructions | string | 可选。针对这些选项要提出的问题。如果不填写,默认问题为“Which option fits the state best?” |
question_name | string | 可选。排序问题在 answers 中的名称。默认为 ranking。 |
top_k | integer | 可选。返回多少个排序后的选项,1 至 255。默认全部返回。 |
assets | object | 可选。具名的 PNG 或 JPEG 图像,state 中可按名称引用。 |
问题类型
每个问题都有一个 type、可选的 instructions,以及描述可能答案的 criteria。
| 类型 | 判断标准 | 答案 |
|---|---|---|
noul | 包含 true 和 false 描述的对象 | noul,即答案为真的概率,大多数模型还会附带 confidence |
choice | 包含 2 至 255 个具名选项的对象 | choice(所选选项),以及每个选项对应的 probabilities(概率)和 confidence(整体置信度) |
score | 由低到高排列的 2 至 10 个级别列表 | score,范围从 0 到最后一个级别的索引,是各级别的概率加权平均值,因此可能落在两个级别之间,另附 legend、每个级别的 probabilities 和 confidence |
box | 无,请在 instructions 中描述要定位的目标。只有 typesafe-jev-1.14 模型可以回答 box 类型的问题 | box(边界框),包含 top、bottom、left 和 right 四个值,均以占图像尺寸的比例表示,另附 confidence(置信度) |
模型可以拒绝回答某个问题。该答案会以 { "type": "refusal" } 返回,表示问题未被回答,而不是答案为否。并非每个模型都接受所有媒体部分,模型无法处理的请求会以状态码 400 失败。
选项排序
发送 options 即可对列表排序。SilentAPI 会针对这些选项提出一个选择题,并在 ranking 中按可能性从高到低返回选项,排在首位的选项放在 choice 中。你可以在同一请求中同时发送 options 和其他 questions。
curl https://api.silentapi.com/v1/decisions \
-H "Authorization: Bearer $SILENTAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"state": "Order 1042 arrived two weeks late and the box was crushed. The customer wants it fixed today.",
"instructions": "What should support do first?",
"options": [
"apologize",
{ "value": "refund", "description": "Return the full payment." },
{ "value": "replace", "description": "Ship a new item by express." }
],
"top_k": 2
}'
{
"object": "decision",
"model": "gemini-decision-1",
"answers": { "ranking": { "type": "choice", "choice": "replace", "probabilities": { "replace": 0.62, "refund": 0.31, "apologize": 0.07 }, "confidence": 0.62 } },
"choice": "replace",
"confidence": 0.62,
"ranking": [
{ "rank": 1, "value": "replace", "probability": 0.62 },
{ "rank": 2, "value": "refund", "probability": 0.31 }
],
"usage": { "input_tokens": 96 },
"silentapi": {
"cost": 0.0000121,
"fallback": null,
"model": "gemini-decision-1",
"model_name": "Gemini Decision 1"
},
"cost": 0.0000121
}
示例
curl https://api.silentapi.com/v1/decisions \
-H "Authorization: Bearer $SILENTAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-decision-1",
"state": { "tier": "business", "ticket": "Checkout shows a blank page after I click Pay." },
"questions": {
"is_bug": { "type": "noul", "instructions": "Is the customer reporting a defect?", "criteria": { "true": "Something is broken.", "false": "A question or a feature request." } },
"team": { "type": "choice", "instructions": "Which team owns this ticket?", "criteria": { "payments": "Checkout and billing.", "frontend": "Layout and rendering.", "account": "Login and profile." } },
"urgency": { "type": "score", "instructions": "How urgent is this ticket?", "criteria": ["Can wait", "This week", "Blocking sales now"] }
}
}'
响应包含每个问题名称对应的一个答案、输入 token 数以及以额度计的费用。
{
"object": "decision",
"model": "gemini-decision-1",
"answers": {
"is_bug": { "type": "noul", "noul": 0.94, "confidence": 0.94 },
"team": {
"type": "choice",
"choice": "payments",
"probabilities": { "payments": 0.88, "frontend": 0.1, "account": 0.02 },
"confidence": 0.88
},
"urgency": {
"type": "score",
"score": 1.72,
"legend": { "0": "Can wait", "1": "This week", "2": "Blocking sales now" },
"probabilities": { "0": 0.04, "1": 0.2, "2": 0.76 },
"confidence": 0.76
}
},
"usage": { "input_tokens": 212 },
"silentapi": {
"cost": 0.0000265,
"fallback": null,
"model": "gemini-decision-1",
"model_name": "Gemini Decision 1"
},
"cost": 0.0000265
}
如果所选模型不可用,且你开启了 Decisions 回退,请求会转到另一个 Decisions 模型。