客服分流
Jev 三题做客服路由:分部门、判紧急、看要不要立刻转人工
痛点
客服最常见的浪费:用户问「发货」「退款」「产品功能」「其他」,全部扔给一个通用的大模型再让大模型判断分给谁,又慢又贵,还容易分错组——分错了还要人工再转一道。
Jev 判断什么
我用三道题覆盖一次分流决策。
department(Choice(选择题)) 问「Which team should handle this message?」,选项 shipping、refund、product、other。这次返回选了 shipping,概率 shipping=0.97、refund=0.03、product=0.0、other=0.0,置信度 0.96。代码直接按选中的选项走派单规则,不用复核。
needs_human(Noul(是非题)) 问「Should this conversation be handed to a human agent right away?」。这次答案为「是」的概率 0.48,正好在 0.5 附近。这种题本身就不该硬判,建议把消息转给人工或让大模型复核。
urgency(Score(打分题)) 问「How urgent is the customer's request?」,档位 0=可以等几天、1=今天处理、2=一小时内处理。这次分数 1.16(档位从 0 开始),各档概率 档位 0 为 0%、档位 1 为 84%、档位 2 为 16%,置信度 0.76。基本判断为「今天处理」,档位 2 也有 16% 概率要兜底。代码可以按 score 向下取整选档位,也可以用最高概率档位派单。
和大模型怎么配合
流程:先把消息塞进 state(上下文状态),调一次 Jev 同时跑这三道题;拿到结果后,代码按 department 派到对应组,按 urgency 决定处理时限,按 needs_human 决定是否转人工。
置信度高的题目(比如这次 department 的 0.96)直接走规则,不调大模型;置信度低的题目,或 needs_human 这类在 0.5 附近不好判的,把消息连同 Jev 的判断一起交给大模型复核。
这次调用 jev-1.14.0 耗时 1098 毫秒,输入 504 个 token,单次 0.000021 美元,每 1000 次约 0.0212 美元。
上线前注意
- 题目用英文写,state 里的中文用户原文保留原样,channel 这种结构化字段直接用。
- 阈值(什么时候算紧急、什么时候转人工)要拿自己 20–30 条真实数据校准,不要直接抄这次的结果当阈值。
- needs_human 概率在 0.5 附近(这次 0.48 就是典型),或 department 置信度低于 0.7,建议交给人工或让大模型复核,不要硬走规则。
- Jev 输出不收费,主要成本是输入 token 长度,state 里 messages 只保留判断需要的几条,不要塞无关历史。
真实调用
请求
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": {
"channel": "在线客服",
"messages": [
{
"from": "用户",
"text": "我昨天买的耳机今天还没发货,明天就要出差了,能不能加急?不行就退款吧"
}
]
},
"questions": {
"department": {
"type": "choice",
"instructions": "Which team should handle this message?",
"criteria": {
"shipping": "Delivery status, delays, or speeding up a shipment",
"refund": "Refunds, returns, or cancelling an order",
"product": "Product features, usage, or quality questions",
"other": "Anything else"
}
},
"needs_human": {
"type": "noul",
"instructions": "Should this conversation be handed to a human agent right away?"
},
"urgency": {
"type": "score",
"instructions": "How urgent is the customer's request?",
"criteria": [
"It can wait several days without upsetting the customer",
"It should be handled today",
"It must be handled within the hour or the customer will leave"
]
}
}
}'import json, os, urllib.request
payload = json.loads("{\n \"model\": \"jev-1.14.0\",\n \"state\": {\n \"channel\": \"在线客服\",\n \"messages\": [\n {\n \"from\": \"用户\",\n \"text\": \"我昨天买的耳机今天还没发货,明天就要出差了,能不能加急?不行就退款吧\"\n }\n ]\n },\n \"questions\": {\n \"department\": {\n \"type\": \"choice\",\n \"instructions\": \"Which team should handle this message?\",\n \"criteria\": {\n \"shipping\": \"Delivery status, delays, or speeding up a shipment\",\n \"refund\": \"Refunds, returns, or cancelling an order\",\n \"product\": \"Product features, usage, or quality questions\",\n \"other\": \"Anything else\"\n }\n },\n \"needs_human\": {\n \"type\": \"noul\",\n \"instructions\": \"Should this conversation be handed to a human agent right away?\"\n },\n \"urgency\": {\n \"type\": \"score\",\n \"instructions\": \"How urgent is the customer's request?\",\n \"criteria\": [\n \"It can wait several days without upsetting the customer\",\n \"It should be handled today\",\n \"It must be handled within the hour or the customer will leave\"\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": {
"department": {
"type": "choice",
"choice": "shipping",
"confidence": 0.96,
"probabilities": {
"shipping": 0.97,
"refund": 0.03,
"product": 0,
"other": 0
}
},
"needs_human": {
"type": "noul",
"noul": 0.48
},
"urgency": {
"type": "score",
"score": 1.16,
"confidence": 0.76,
"legend": {
"0": "It can wait several days without upsetting the customer",
"1": "It should be handled today",
"2": "It must be handled within the hour or the customer will leave"
},
"probabilities": {
"0": 0,
"1": 0.84,
"2": 0.16
}
}
},
"usage": {
"input_tokens": 504,
"output_tokens": 78
}
}人话解读
- Choice:选了 shipping,置信度 0.96
- Noul:「是」的概率 0.48
- Score:档位 1(It should be handled today),分数 1.16,置信度 0.76