外观
API 参考
接口
所有响应使用 { "ok": true, "data": ... } 或 { "ok": false, "error": "..." } 格式。
GET /health
bash
curl http://127.0.0.1:9930/health响应:
json
{
"ok": true,
"data": {
"service": "llm-nlu-server"
}
}GET /api/v1/nlu/capabilities
返回当前服务注册的 action 与 profile 元数据,不暴露 prompt、模型地址、超时等执行细节。
bash
curl http://127.0.0.1:9930/api/v1/nlu/capabilities如启用鉴权:
bash
curl http://127.0.0.1:9930/api/v1/nlu/capabilities \
-H "X-Callout-Internal-Token: <token>"POST /api/v1/nlu:decision
用于把客户当前话术归类到给定 branches 之一。
bash
curl -s -X POST http://127.0.0.1:9930/api/v1/nlu \
-H "Content-Type: application/json" \
-H "X-Callout-Internal-Token: <token>" \
-d '{
"action": "decision",
"profile": "sales-intent",
"text": "可以,你简单介绍一下",
"branches": [
{ "key": "interested", "desc": "愿意继续沟通" },
{ "key": "reject", "desc": "拒绝或不方便" }
]
}'响应:
json
{
"ok": true,
"data": {
"key": "interested",
"confidence": 0.82,
"reason": "客户表示可以继续了解"
}
}POST /api/v1/nlu:extract
用于从客户话术中抽取结构化字段。
bash
curl -s -X POST http://127.0.0.1:9930/api/v1/nlu \
-H "Content-Type: application/json" \
-H "X-Callout-Internal-Token: <token>" \
-d '{
"action": "extract",
"profile": "customer-base",
"text": "我姓张,今年 35 岁,下午三点以后方便",
"fields": [
{ "key": "name", "label": "姓名", "type": "text" },
{ "key": "age", "label": "年龄", "type": "number" },
{ "key": "callbackTime", "label": "回访时间", "type": "text" }
]
}'响应:
json
{
"ok": true,
"data": {
"fields": {
"name": "张",
"age": 35,
"callbackTime": "下午三点以后"
},
"confidence": 0.78,
"reason": "客户明确提供了姓氏、年龄和方便回访时间"
}
}