Mirror Search API
wgHub 等上游通过本接口做规则意图检索。返回单条 tool_call,已与 wgHub tool 格式对齐。
POST
/v1/mirror/search
Content-Type: application/json
请求参数
| 参数 | 必填 | 默认 | 说明 |
|---|---|---|---|
query | 是 | — | 用户说法,整句 ASR 文本 |
debug | 否 | false | 为 true 时额外返回 debug_detail(模板对齐路径);生产保持 false |
recall_terminal | 否 | null | intent 白名单;可抵消默认黑名单(问卷 step 放行) |
block_terminal | 否 | null | intent 黑名单,优先级最高 |
最小请求
JSON
{
"query": "下一页"
}
问卷 step 放行
JSON
{
"query": "安静",
"recall_terminal": ["new_user_energy_choice"]
}
响应体
| 字段 | 说明 |
|---|---|
tool_call | 单条 wgHub tool;未命中为 null |
tool_call.tool | tool 名,如 turn_page、switch_account |
tool_call.arguments | tool 参数对象 |
tool_call.score | 匹配得分 0~1 |
debug_detail | 仅 debug=true;含 tag_segment / word_segment / slot |
error_code | 引擎错误码,0 为正常 |
elapsed_ms | 检索耗时(毫秒) |
debug | 是否 debug 模式 |
响应示例
命中 — 翻页
200 OK
{
"tool_call": {
"tool": "turn_page",
"arguments": { "action": "next" },
"score": 1.0
},
"error_code": 0,
"elapsed_ms": 1.23,
"debug": false
}
命中 — 切换账号(带槽位)
200 OK
{
"tool_call": {
"tool": "switch_account",
"arguments": { "user_name": "小明" },
"score": 0.96
},
"error_code": 0,
"elapsed_ms": 0.85,
"debug": false
}
命中 — 快速模式
200 OK
{
"tool_call": {
"tool": "fast_mode",
"arguments": {},
"score": 0.92
},
"error_code": 0,
"elapsed_ms": 0.58,
"debug": false
}
命中 — 穿搭推荐
200 OK
{
"tool_call": {
"tool": "quick_recommend",
"arguments": { "need": "通勤风" },
"score": 0.85
},
"error_code": 0,
"elapsed_ms": 0.71,
"debug": false
}
未命中
200 OK
{
"tool_call": null,
"error_code": 0,
"elapsed_ms": 0.42,
"debug": false
}
change_cloth 命中
200 OK · remove
{
"tool_call": {
"tool": "change_cloth",
"arguments": { "action": "remove" },
"score": 0.95
},
"error_code": 0,
"elapsed_ms": 0.61,
"debug": false
}
cURL
shell
curl -s -X POST http://127.0.0.1:51081/v1/mirror/search \
-H 'Content-Type: application/json' \
-d '{"query":"下一页"}'
Tool 映射
引擎内部 intent 会映射为 wgHub tool 名与 arguments:
| 引擎 intent | tool | arguments |
|---|---|---|
turn_page_next | turn_page | { "action": "next" } |
turn_page_prev | turn_page | { "action": "prev" } |
auto_scroll_next | auto_scroll | { "direction": "next" } |
auto_scroll_prev | auto_scroll | { "direction": "prev" } |
change_cloth_replace | change_cloth | { "action": "replace" } |
change_cloth_add | change_cloth | { "action": "add" } |
change_cloth_remove | change_cloth | { "action": "remove" } |
outfit_recommend | quick_recommend | { "need": "场景/单品…" },多段时直接拼接 |
record_mode_exit | back | {} |
deep_mode_exit | back | {} |
fast_mode_exit | back | {} |
其他 intent | 同名 | 槽位展平为 arguments |
服务固定项
以下策略由服务内部固定,上游无需传,也请勿依赖修改。
multi_terminal=false— 只返回最高分一条punctuation=clean— 匹配时跳过标点cut_with_symbol=true— 首次未命中时,从第一个标点切分,对后半段再检索一次(标点前 ≤ 总长一半才触发)use_default_block=true— 始终屏蔽问卷三题 intent;问卷 step 用 recall_terminal 放行
其他接口
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /health | 服务状态、intent 数量 |
| GET | /v1/mirror/intents | 已加载 intent 列表 |
| GET | /debug | 可视化调试台 |