Local semantic message routing for multi-agent systems. Routes messages to the correct agent based on embeddings + keyword + context scoring. No external APIs, no cloud dependencies, works on ARM64. 100% accuracy on benchmark with domain-augmented embeddings and action verb stratification.
使用三层评分架构将消息路由到多智能体系统中的正确智能体:
大多数智能体路由器要么:
本路由器完全本地运行,每次查询约1.5毫秒,准确率100%。
创建路由配置文件(JSON或Python字典):
python
ROUTES = {
ops: {
agent: orion,
descriptions: [
部署和管理基础设施及Docker容器,
安装、配置和重启服务,
DevOps运维、CI/CD、部署流水线,
],
keywords: [deploy, install, docker, compose, container, restart],
action_verbs: [déploie, installe, configure, redémarre],
},
security: {
agent: aegis,
descriptions: [
安全审计、漏洞扫描、加固,
防火墙规则、SSL证书、访问控制,
],
keywords: [security, firewall, ssl, vulnerability],
action_verbs: [sécurise, hardened],
},
# ... 添加更多路由
}
python
from semantic_router import SemanticRouter
router = SemanticRouter(routes_config=routes.json)
router.initialize() # 构建ChromaDB索引(冷启动约6秒,之后缓存)
result = router.route(在家庭实验室部署新的监控栈)
bash
输入消息
│
├─► 法语标准化(口音处理、动词映射)
│
├─► 第一层:嵌入相似度(ChromaDB)
│ └─ 与路由描述进行余弦相似度计算
│
├─► 第二层:关键词评分
│ └─ 精确/子串匹配,避免关键词冲突
│
├─► 第三层:动作动词分层
│ └─ 运维动词 → 始终覆盖主题
│ └─ 主题动词 → 覆盖但限于特定路由
│ └─ 弱动词 → 让嵌入决定
│
└─► 加权融合 → 路由选择
最终得分 = (0.4 × 质心相似度) + (0.3 × 最大示例相似度) + (0.3 × 关键词得分) + 动作提升
其中动作提升对匹配的动作动词进行加分,允许覆盖嵌入得分。
| 端点 | 方法 | 描述 |
|---|---|---|
| /route | POST | 路由单条消息 |
| /batch |
| 指标 | 数值 |
|---|---|
| 准确率(基准测试) | 100%(41/41条消息) |
| 查询延迟 |
semantic-router/
├── SKILL.md ← 本文件
├── scripts/
│ ├── semantic_router.py ← 核心路由库
│ └── router-api.py ← REST API封装
└── references/
└── ROUTING-RESEARCH.md ← 设计笔记和基准测试
MIT — 自由使用,欢迎注明出处。
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 chromadb-agent-router-1775941501 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 chromadb-agent-router-1775941501 技能
skillhub install chromadb-agent-router-1775941501
文件大小: 9.45 KB | 发布时间: 2026-4-12 09:22