聊天副驾
把「对方想要什么」「该不该现在回」「哪条回复合适」拆成 Jev 的三道题,由置信度决定交给人还是大模型。
痛点
大模型会写回复,但看不准对方真实意思,也不知道这时候该不该回。把判断全压给大模型直接出回复,经常出现「写得漂亮但时机和态度全错」的情况。
Jev 判断什么
state(上下文状态)就是交给 Jev 判断的内容。这次是一段三句的微信聊天:对方质问我昨天为什么没来,我解释临时加班忘了说,对方回了句「算了,没事」。
我准备了 3 道题,题型分别是 Choice(选择题)和 Noul(是非题),每题只负责一件事。
题 1:intent(Choice) 问「What does the other person most want right now?」,4 个选项覆盖最常见的几种诉求。这次返回选了 apology,概率分布 apology=0.89, really_fine=0.01, end_chat=0.09, explanation=0.01,置信度(confidence)0.85。
读法:置信度 0.85 算高,可以信任。对方嘴上说「算了没事」,Jev 判断真实诉求是道歉和关注,不是真的没事、也不是想结束对话。
代码里按 state.intent == "apology" 走「道歉 + 关注」的分支,really_fine 直接走「不需要回复」,end_chat 走「暂停」。
题 2:reply_now(Noul) 问「Should I reply right away instead of waiting?」,返回「是」的概率 0.73。
读法:Noul 是「是/否」题,0.73 明显倾向立刻回。这里可以设一个阈值(threshold),比如 ≥0.6 就立即推送,0.4–0.6 之间延迟一会儿再看,<0.4 等下一轮。
代码里直接读 state.reply_now 的概率,配合业务规则决定推送时机。
题 3:best_reply(Choice) 问「Which candidate reply fits the situation best?」,4 个候选回复。这次返回选了 r1「对不起,是我不对,周末我请你吃饭补上」,概率分布 r1=0.98, r2=0.02, r3=0.0, r4=0.0,置信度 0.97。
读法:置信度 0.97,几乎可以无脑采用 r1。如果候选回复是大模型生成的,可以把 Jev 的选择当作 rerank 的依据,只展示它选中的那条。
代码里读 state.best_reply 得到选项 ID,对应到准备好的回复文案,或者直接从候选列表里取索引。
和大模型怎么配合
流程是「Jev 先判断 → 按置信度分流」。Jev 一次返回里同时拿到 intent、reply_now、best_reply 的结果:
- intent 选 really_fine 且置信度高:根本不调大模型,直接不回复或回一个表情。
- intent 选 end_chat 且置信度高:不调大模型,建议用户暂停对话。
- best_reply 置信度 ≥0.9:直接把 Jev 选的候选当最终回复,不用再让大模型重写。
- 其他情况:把 Jev 的判断作为上下文喂给大模型,让它基于「对方想要道歉」这个结论润色或生成新回复;或者交给人工复核。
这次调用用的是 jev-1.14.0,耗时 1047 毫秒,输入 574 个 token,花费 0.000024 美元。按这个量算,每 1000 次约 0.0241 美元,比让大模型直接处理便宜。
上线前注意
- 题目里的 criteria(判定标准)和 instructions(指令)用英文写,state 里的聊天内容保留中文原文,Jev 对中英混排 state 做过实测。
- 置信度阈值(0.9、0.6、0.4 这些)不要直接抄我的,要用自己场景下 20–30 条真实数据校准。
- 置信度低于 0.6,或者 Noul 题的结果落在 0.5 附近时,直接交给人或大模型复核,不要硬走规则。
- reply_now 这道题对历史节奏敏感,同样一句「算了没事」在吵架后和日常聊天的意思完全不同,state 里如果能带上最近几条消息的发送时间间隔,判断会更准。
真实调用
请求
curl https://api.typesafe.ai/v1/systemone \
-H "Authorization: Bearer $TYPESAFE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "jev-1.14.0",
"state": {
"messages": [
{
"from": "对方",
"text": "你昨天说好要来的,结果呢"
},
{
"from": "我",
"text": "临时加班了,忘了跟你说"
},
{
"from": "对方",
"text": "算了,没事"
}
]
},
"questions": {
"intent": {
"type": "choice",
"instructions": "What does the other person most want right now?",
"criteria": {
"apology": "A sincere apology and some attention",
"really_fine": "Nothing; they are genuinely fine",
"end_chat": "To end the conversation",
"explanation": "A detailed explanation of what happened"
}
},
"reply_now": {
"type": "noul",
"instructions": "Should I reply right away instead of waiting?"
},
"best_reply": {
"type": "choice",
"instructions": "Which candidate reply fits the situation best?",
"criteria": {
"r1": "对不起,是我不对,周末我请你吃饭补上",
"r2": "真的没事吗?那就好",
"r3": "加班我也没办法啊",
"r4": "那下次再约吧"
}
}
}
}'import json, os, urllib.request
payload = json.loads("{\n \"model\": \"jev-1.14.0\",\n \"state\": {\n \"messages\": [\n {\n \"from\": \"对方\",\n \"text\": \"你昨天说好要来的,结果呢\"\n },\n {\n \"from\": \"我\",\n \"text\": \"临时加班了,忘了跟你说\"\n },\n {\n \"from\": \"对方\",\n \"text\": \"算了,没事\"\n }\n ]\n },\n \"questions\": {\n \"intent\": {\n \"type\": \"choice\",\n \"instructions\": \"What does the other person most want right now?\",\n \"criteria\": {\n \"apology\": \"A sincere apology and some attention\",\n \"really_fine\": \"Nothing; they are genuinely fine\",\n \"end_chat\": \"To end the conversation\",\n \"explanation\": \"A detailed explanation of what happened\"\n }\n },\n \"reply_now\": {\n \"type\": \"noul\",\n \"instructions\": \"Should I reply right away instead of waiting?\"\n },\n \"best_reply\": {\n \"type\": \"choice\",\n \"instructions\": \"Which candidate reply fits the situation best?\",\n \"criteria\": {\n \"r1\": \"对不起,是我不对,周末我请你吃饭补上\",\n \"r2\": \"真的没事吗?那就好\",\n \"r3\": \"加班我也没办法啊\",\n \"r4\": \"那下次再约吧\"\n }\n }\n }\n}")
headers = {
"Authorization": "Bearer " + os.environ["TYPESAFE_API_KEY"],
"Content-Type": "application/json",
}
req = urllib.request.Request(
"https://api.typesafe.ai/v1/systemone",
data=json.dumps(payload).encode("utf-8"),
headers=headers,
method="POST",
)
print(urllib.request.urlopen(req).read().decode("utf-8"))
返回
{
"model": "jev-1.14.0",
"answers": {
"intent": {
"type": "choice",
"choice": "apology",
"confidence": 0.85,
"probabilities": {
"apology": 0.89,
"really_fine": 0.01,
"end_chat": 0.09,
"explanation": 0.01
}
},
"reply_now": {
"type": "noul",
"noul": 0.73
},
"best_reply": {
"type": "choice",
"choice": "r1",
"confidence": 0.97,
"probabilities": {
"r1": 0.98,
"r2": 0.02,
"r3": 0,
"r4": 0
}
}
},
"usage": {
"input_tokens": 574,
"output_tokens": 117
}
}人话解读
- Choice:选了 apology,置信度 0.85
- Noul:「是」的概率 0.73
- Choice:选了 r1,置信度 0.97