agent-foundation/docs/semantic-routing.md
2026-07-21 13:00:02 +08:00

47 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 企业微信语义路由
## 调用链
企业微信文本消息统一经过:
1. 回调验签、解密和消息去重。
2. DeepSeek 只输出结构化意图和日期参数。
3. 后端根据意图选择预注册的白名单处理器。
4. 处理器根据企业微信 UserID 调用对应业务接口。
5. 后端将结构化结果格式化成企业微信文本并发送。
模型不能输出或调用任意 URL,也不能传入校区、顾问或权限范围。业务接口仍会根据企业微信 UserID 做最终权限校验。
## 已支持意图
### CUSTOMER_DAILY_REPORT
- 示例:`查看今日客资管理日报`
- 支持:今日、昨日、本周、上周、本月、上月、明确的单日或日期范围。
- 调用:`POST /api/crm/daily-report`
- 请求参数:`startDate`、`endDate`、`wecomUserId`
## 扩展新意图
新增一个 Spring Bean,实现 `SemanticIntentHandler`:
```java
@Component
public class ExampleIntentHandler implements SemanticIntentHandler {
public String intent() { return "EXAMPLE_INTENT"; }
public String description() { return "意图用途和触发语义"; }
public String example() { return "企业微信中的示例问法"; }
public String handle(SemanticRequestContext context, SemanticRecognition recognition) {
return "处理结果";
}
}
```
处理器会自动加入 DeepSeek 可选意图目录和后端路由表,不需要修改中心 `switch`。如果意图重复,应用启动时直接失败,避免路由覆盖。
## 容错
- DeepSeek 暂时不可用或返回非 JSON 时,已知高频指令可以走受限关键词兜底。
- 低于置信度阈值或未知意图不会调用业务接口,只返回支持的示例。
- 人员未映射或不在组织权限范围内时,日报服务返回 403,企业微信显示“无权限查看”。