跳到主要内容

决策模型(System One)

决策模型根据一份 state 回答一组问题,返回是非概率、选项或量表分值。适用于分类、判断和评分,响应为非流式 JSON。

接口与鉴权​

操作方法与路径
决策请求POST /v1/systemone
可用决策模型GET /v1/models?output_modalities=decision
TypeSafe SDK 兼容请求POST /typesafe/v1/systemone
TypeSafe 格式模型列表GET /typesafe/v1/models
BASE_URL="https://api.ope.ai"
API_KEY="YOUR_API_KEY"

curl "$BASE_URL/v1/models?output_modalities=decision" \
-H "Authorization: Bearer $API_KEY"

示例使用 jev,请按当前可用列表替换为实际模型 ID。决策模型通过 systemone 入口调用。

请求字段​

字段类型必填说明
modelstring是非空决策模型 ID
statestring / object / array是所有问题共同评估的文本或 JSON 内容
questionsobject是至少一项,键为自定义问题名,值为问题定义
questions.<名称>.typestring是noul、choice 或 score
questions.<名称>.instructionsstring / object / array / null否问题说明
questions.<名称>.criteriaobject / array按类型见下表
问题类型criteria答案字段
noul可选对象,例如 {"true":"满足条件","false":"不满足条件"}noul:为真的概率,范围 0–1
choice必填对象:选项名 → 说明choice:选项名;confidence、probabilities
score必填非空数组:按档位顺序排列,下标为分值score:加权分值;confidence、legend、probabilities

curl:一次请求包含三类问题​

curl "$BASE_URL/v1/systemone" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
--data '{
"model": "jev",
"state": "我的付款已经失败三天了,请尽快解决!",
"questions": {
"is_urgent": {"type": "noul", "instructions": "客户是否表达了紧急需求?"},
"department": {
"type": "choice",
"instructions": "应该由哪个团队处理?",
"criteria": {"billing": "支付、账单、退款", "technical": "故障、接口、系统问题"}
},
"frustration": {
"type": "score",
"instructions": "客户的不满程度如何?",
"criteria": ["平静", "不满", "非常愤怒"]
}
}
}'

HTTP 200 响应示例(概率与分值仅作演示):

{
"model": "jev-1.13.0",
"answers": {
"is_urgent": {"type": "noul", "noul": 0.95},
"department": {
"type": "choice",
"choice": "billing",
"confidence": 0.8,
"probabilities": {"billing": 0.87, "technical": 0.13}
},
"frustration": {
"type": "score",
"score": 1.04,
"confidence": 0.94,
"legend": {"0": "平静", "1": "不满", "2": "非常愤怒"},
"probabilities": {"0": 0, "1": 0.96, "2": 0.04}
}
},
"usage": {"input_tokens": 426, "output_tokens": 73}
}

answers 的键与 questions 一致;答案的 type 与问题类型一致。model 为实际作答版本,可能与请求 ID 不同。usage.input_tokens、usage.output_tokens 分别表示输入和输出 token 数。

score 可以是小数;legend 和 probabilities 用字符串下标表示量表档位。根据业务需要解读概率与分值,示例数值不代表固定判断结果。

TypeSafe SDK 接入​

使用 TypeSafe SDK 时,将 baseURL 设置为 https://api.ope.ai/typesafe,apiKey 设置为平台 API Key;SDK 兼容入口的请求与响应结构相同。

export TYPESAFE_BASE_URL="https://api.ope.ai/typesafe"
export TYPESAFE_API_KEY="YOUR_API_KEY"

错误​

错误使用 detail 字段。结构错误通常为 HTTP 422,loc 指向问题字段:

{
"detail": [{
"loc": ["body", "questions", "frustration", "score", "criteria"],
"msg": "Field required",
"type": "missing"
}]
}

常见状态:402 额度不足,403 权限或内容限制,404 模型不存在或非决策模型,422 请求结构或参数不合法,429 限流,503 服务暂不可用。其他错误的 detail 可以是字符串,并可能带 type、code。