JEV 决策 (TypeSafe)
JEV 是 TypeSafe 的决策模型。你给它一段上下文(state)和一组带类型的问题(questions),它一次调用返回结构化答案:每个答案都带概率分布,而不是一段还要你自己解析的自由文本。适合工单路由、意图识别、内容审核、情绪打分这类判断与分类任务。
创建决策
POST https://ciyuanx.io/inference/jev/api/alpha/decisions
注意
这个端点不在 /v1 兼容层下,请求体也和 Chat Completions 不同,不能用 OpenAI SDK 直接调用,按下面的示例发普通 HTTP 请求即可。路径中的 alpha 表示接口仍处于早期阶段,字段可能调整。
curl https://ciyuanx.io/inference/jev/api/alpha/decisions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "jev",
"state": "Help! My payouts have been failing for 3 days.",
"questions": {
"is_urgent": {
"type": "noul",
"instructions": "Does this message convey urgency?",
"criteria": {
"true": "Explicitly time-sensitive",
"false": "No urgency expressed"
}
},
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"billing": "Payments, invoicing, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades, new accounts"
}
},
"frustration": {
"type": "score",
"instructions": "How frustrated is the customer?",
"criteria": ["Calm", "Frustrated", "Very angry"]
}
}
}'import requests
response = requests.post(
"https://ciyuanx.io/inference/jev/api/alpha/decisions",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY",
},
json={
"model": "jev",
"state": "Help! My payouts have been failing for 3 days.",
"questions": {
"is_urgent": {
"type": "noul",
"instructions": "Does this message convey urgency?",
"criteria": {
"true": "Explicitly time-sensitive",
"false": "No urgency expressed",
},
},
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"billing": "Payments, invoicing, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades, new accounts",
},
},
"frustration": {
"type": "score",
"instructions": "How frustrated is the customer?",
"criteria": ["Calm", "Frustrated", "Very angry"],
},
},
},
)
answers = response.json()["answers"]
print(answers["department"]["choice"]) # billing
print(answers["frustration"]["score"]) # 1.04
print(answers["is_urgent"]["noul"]) # 0.95const response = await fetch(
"https://ciyuanx.io/inference/jev/api/alpha/decisions",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer YOUR_API_KEY",
},
body: JSON.stringify({
model: "jev",
state: "Help! My payouts have been failing for 3 days.",
questions: {
is_urgent: {
type: "noul",
instructions: "Does this message convey urgency?",
criteria: {
true: "Explicitly time-sensitive",
false: "No urgency expressed",
},
},
department: {
type: "choice",
instructions: "Which team should handle this?",
criteria: {
billing: "Payments, invoicing, refunds",
technical: "Bugs, outages, integrations",
sales: "Pricing, upgrades, new accounts",
},
},
frustration: {
type: "score",
instructions: "How frustrated is the customer?",
criteria: ["Calm", "Frustrated", "Very angry"],
},
},
}),
},
);
const { answers } = await response.json();
console.log(answers.department.choice); // billing
console.log(answers.frustration.score); // 1.04
console.log(answers.is_urgent.noul); // 0.95请求参数
| 参数 | 类型 | 必需 | 描述 |
|---|---|---|---|
model | string | 是 | 模型 ID,填 jev;响应会返回实际使用的版本 |
state | string | 是 | 待判断的上下文文本,例如一条用户消息、一封邮件或一段会话记录 |
questions | object | 是 | 问题集合。键由你自己定义,答案会用同样的键返回 |
questions 中每个问题的结构:
| 字段 | 类型 | 必需 | 描述 |
|---|---|---|---|
type | string | 是 | 问题类型:noul、choice 或 score |
instructions | string | 是 | 用自然语言说明这道题要判断什么 |
criteria | object 或 array | 是 | 判断标准,写法取决于 type |
问题类型
noul — 是否判断
criteria 用 true 和 false 两个键,分别描述「成立」和「不成立」的情形。
"is_urgent": {
"type": "noul",
"instructions": "Does this message convey urgency?",
"criteria": {
"true": "Explicitly time-sensitive",
"false": "No urgency expressed"
}
}答案返回一个 noul 字段,是 0–1 的概率,表示条件成立的可能性(0.95 即「大概率紧急」)。这个类型不返回 confidence,概率本身就是强度。
choice — 单项选择
criteria 是「选项 → 该选项含义」的对象,模型从中挑一个。
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"billing": "Payments, invoicing, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades, new accounts"
}
}答案返回选中的 choice、所有选项的 probabilities,以及 confidence。
score — 分档打分
criteria 是一个有序数组,下标就是分值:第 0 项对应 0 分,第 1 项对应 1 分,依此类推。
"frustration": {
"type": "score",
"instructions": "How frustrated is the customer?",
"criteria": ["Calm", "Frustrated", "Very angry"]
}答案返回连续的 score、把下标映射回档位文字的 legend、每一档的 probabilities,以及 confidence。score 是按概率加权的期望值,所以通常落在两档之间:示例中 0 × 0 + 1 × 0.96 + 2 × 0.04 = 1.04。
响应
{
"model": "typesafe/jev-1.13-20260917",
"answers": {
"department": {
"type": "choice",
"choice": "billing",
"probabilities": {
"technical": 0.11,
"sales": 0,
"billing": 0.89
},
"confidence": 0.83
},
"frustration": {
"type": "score",
"score": 1.04,
"legend": {
"0": "Calm",
"1": "Frustrated",
"2": "Very angry"
},
"probabilities": {
"0": 0,
"1": 0.96,
"2": 0.04
},
"confidence": 0.95
},
"is_urgent": {
"type": "noul",
"noul": 0.95
}
},
"usage": {
"input_tokens": 427,
"output_tokens": 73,
"cost": 0.000017934
},
"id": "gen-dec-1789948229-FmHnDQNsDfVnwWsYaUP1",
"provider": "TypeSafe"
}响应字段
顶层字段:
| 字段 | 类型 | 描述 |
|---|---|---|
model | string | 实际使用的模型版本,例如 typesafe/jev-1.13-20260917 |
answers | object | 答案集合,键与请求中的 questions 一一对应 |
usage | object | 本次调用的 token 用量与费用 |
id | string | 本次请求的唯一 ID,排查问题时提供给支持人员 |
provider | string | 实际服务商,此处为 TypeSafe |
答案对象字段(按 type 区分):
| 字段 | 出现在 | 类型 | 描述 |
|---|---|---|---|
type | 全部 | string | 与提问时的 type 一致 |
noul | noul | number | 条件成立的概率,0–1 |
choice | choice | string | 选中的选项键 |
score | score | number | 概率加权后的分值,连续值 |
legend | score | object | 下标 → 档位文字的映射 |
probabilities | choice、score | object | 各选项 / 各档位的概率,合计约为 1 |
confidence | choice、score | number | 模型对该答案的置信度,0–1;与 probabilities 分开给出,不等于最大概率值 |
usage 字段:
| 字段 | 类型 | 描述 |
|---|---|---|
input_tokens | integer | 输入 token 数(state 与全部问题定义) |
output_tokens | integer | 输出 token 数 |
cost | number | 本次调用的费用(美元) |
最佳实践
把判断标准写进 criteria
instructions说清楚要判断什么,criteria说清楚每个结果的边界——把边界写细,比把instructions写长更有效- 问题的键名就是答案的键名,用
is_urgent、department这类语义化命名,拿到响应可以直接取值入库
用概率做路由
- 不要只看
choice,同时检查confidence和probabilities:低于阈值的转人工处理 score是连续值,需要离散档位时按probabilities取最大项,或自行取整
合并请求
- 同一段
state上的多个问题放进一次请求,state只发送和计费一次,比拆成多次调用更省 token
提示
答案按键返回,顺序不保证与提问顺序一致(上面的示例响应就重新排过序)。取值请用键名,不要依赖顺序。