feat: 添加 AI Agent 对话测试工具 + 代码优化

主要变更:

- 新增 tests/test_ai_chat.py: AI Agent 对话测试工具

- 优化 core/pydantic_ai_agent.py 和 db/chat_log_db.py

- 清理归档文件,更新文档

Made-with: Cursor
This commit is contained in:
2026-02-28 16:19:35 +08:00
parent a6c42d505a
commit c39840fe15
49 changed files with 2453 additions and 8556 deletions

View File

@@ -1,4 +1,4 @@
# 配置文件
# 配置文件说明
## transfer_groups.json
@@ -18,19 +18,47 @@
---
## 设计师派单SQLite,可选
## 设计师派单SQLite
同一设计师在不同店铺对应不同 group_id转人工时按需查询在线状态从在线设计师中轮询派单。
**初始化数据**
### 数据库
路径: `db/designer_roster_db/roster.db`
| 表 | 说明 |
|---|------|
| `designers` | 设计师name, wechat_user_id|
| `designer_shops` | 设计师在某店铺的 group_id同一人不同店铺不同分组|
| `designer_online` | 在线状态(转人工时按需查询外部 API 同步)|
### 初始化数据
```bash
python scripts/init_designer_roster.py example # 写入示例
python scripts/init_designer_roster.py list # 查看当前数据
```
**数据库**`db/designer_roster_db/roster.db`
- `designers`设计师name, wechat_user_id
- `designer_shops`:设计师在某店铺的 group_id同一人不同店铺不同分组
- `designer_online`:在线状态(转人工时按需查询外部 API 同步)
### 在线查询 API
**接入**`.env` 配置 `DESIGNER_ROSTER_API`(如 `http://xxx/online`),转人工时 GET 一次,用 `online_users` 同步。无人在线时发企微「谁在线啊」
`.env` 配置 `DESIGNER_ROSTER_API`(如 `http://huichang.online:8001/online`
**接口**: GET返回格式
```json
{
"online_count": 2,
"online_users": ["lz", "ZuoWei"],
"update_time": "2026-02-26 16:30:00"
}
```
| 字段 | 必填 | 说明 |
|------|------|------|
| `online_users` | 是 | 当前在线设计师名单,对应 `wechat_user_id` |
**调用时机**: 转人工时按需 GET 一次,不轮询。无人在线时回退到 `transfer_groups.json` 静态配置,并发企微「谁在线啊」提醒。
### 对接方要求(外部 AI 服务)
对端需实现:企微群消息 → 解析「上线」/「下线」→ 存库 → 提供 GET `/online` 接口,按上述格式返回在线名单。