TypeSafe Decisions
使用 Jev 进行条件判断、分类、评分和工具选择。
Decisions 使用 Jev 对文本或业务状态进行判断,返回可直接在代码中读取的答案。接口同步返回 JSON,不支持流式响应。
/v1/decisionsAuthorization
bearerAuth 使用当前站点签发的 API Key。
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
请求示例
以下示例使用 jev-1.13.0。选择问题场景和代码语言后,可复制对应请求。
是否请求退款
curl --request POST 'https://api.agtcloud.cn/v1/decisions' \
--header 'Authorization: Bearer your-api-key' \
--header 'Content-Type: application/json' \
--data '{
"model": "jev-1.13.0",
"state": "My subscription was charged twice. Please refund the duplicate charge.",
"questions": {
"ticket": {
"type": "noul",
"instructions": "Does the customer explicitly request a refund?",
"criteria": {
"true": "The message explicitly asks for a refund.",
"false": "The message does not ask for a refund."
}
}
}
}'问题类型
| 类型 | 用途 | 返回内容 |
|---|---|---|
noul | 判断条件是否成立,例如客户是否请求退款 | noul:条件成立的概率 |
choice | 从候选项中选择分类或动作,例如工单处理部门 | choice、probabilities、confidence |
score | 按照有序标准评分,例如工单紧急程度 | score、legend、probabilities、confidence |
通过 state 提供待判断的内容,在 questions 中填写问题及标准。同一请求可以包含多个问题,也可以混合三种类型;每个问题共享同一个 state。
读取结果
answers 使用与 questions 相同的问题 ID。例如问题 ID 为 ticket 时,从 answers.ticket 读取答案。
- 判断:读取
noul。数值范围为 0~1,接近 1 表示倾向成立,接近 0 表示倾向不成立;根据业务需要设置判断阈值。 - 分类:读取
choice获取选项名称,使用probabilities查看各选项概率。 - 评分:读取
score。等级按criteria的数组位置从 0 编号;三档标准对应 0~2,评分可以为小数。legend提供等级编号与说明的对应关系。
choice 和 score 的 confidence 表示概率分布的确定程度,不等于答案正确率。概率、评分和 Token 用量会随请求变化。
工具选择使用 choice 返回动作名称,例如 lookup_payment。应用根据该名称执行后续操作;本次决策请求不会执行工具,也不会生成 OpenAI tool_calls。
Token 用量与费用
usage.input_tokens 和 usage.output_tokens 分别记录输入、输出 Token 用量。Jev 按输入 Token 计费,输出 Token 不收费;多个问题及候选说明也会影响输入用量。当前价格请查看 模型广场。