feat(agent): 医院信息子代理改为本地文件知识库并接入双 bot
- 一院一 Markdown 档案(data/hospitals),索引与章节自动维护;读取支持 section 与 24k 截断,写入校验日期与单条长度,别名精确冲突时不新建 - 子代理按 allowWrite 分可写/只读工具集与提示词:管理端与陪诊员可写,就诊人端只读(物理移除写入工具) - 新增 scripts/import_hospitals.js 存量导入:压缩医生为一行、默认前 60 位,支持 dry-run、幂等与冲突报告,生成 112 家医院档案 - 管理端图片识别原文沿用原样回显策略,不再经模型二次整理 - npm test 212 项通过(新增知识库 12 项、导入 3 项)
This commit is contained in:
@@ -2,6 +2,7 @@ import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import EscortAgent from "../agent/bots/bot-escort/agent.js";
|
||||
import EscortAdminAgent from "../agent/bots/bot-escort-admin/agent.js";
|
||||
|
||||
// 一份超过护栏 400 字上限的识别原文:用来确认回显分支不再截断长报告
|
||||
const IMAGE_TEXT = [
|
||||
@@ -58,3 +59,31 @@ test("空白识别原文不投递", async () => {
|
||||
assert.equal(chunks.length, 0);
|
||||
assert.equal(agent.messages.length, 0);
|
||||
});
|
||||
|
||||
test("陪诊师端图片识别原文完整回显,不经过模型与输出护栏", async () => {
|
||||
const agent = new EscortAdminAgent();
|
||||
const chunks = [];
|
||||
const user = { _id: "admin-format-user", profile: {}, location: {} };
|
||||
|
||||
await agent.streamChat(
|
||||
user,
|
||||
[{ type: "format", ts: "2026-11-01 10:00:00", content: IMAGE_TEXT, id: "req_admin_format" }],
|
||||
(source, type, content, id) => {
|
||||
chunks.push({ source, type, content, id });
|
||||
},
|
||||
"admin"
|
||||
);
|
||||
|
||||
assert.ok(chunks.length > 1);
|
||||
assert.equal(chunks.map(item => item.content).join(""), IMAGE_TEXT);
|
||||
assert.deepEqual(new Set(chunks.map(item => item.id)), new Set(["req_admin_format"]));
|
||||
assert.deepEqual(new Set(chunks.map(item => item.source)), new Set(["main"]));
|
||||
assert.deepEqual(new Set(chunks.map(item => item.type)), new Set(["ai"]));
|
||||
|
||||
// 原文进会话历史,后续追问图片内容时模型能看到
|
||||
const session = agent.sessions.get(user._id);
|
||||
assert.equal(session.messages.length, 1);
|
||||
assert.match(session.messages[0].text, /白细胞计数 WBC 6\.2/);
|
||||
// 走回显分支时不构建 agent,也就不会产生模型调用
|
||||
assert.equal(session.agent, null);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user