调整了agent

This commit is contained in:
lik
2026-10-28 11:15:29 +08:00
parent b8f53d3660
commit c4f6be6494
29 changed files with 703 additions and 921 deletions
+5 -2
View File
@@ -1,6 +1,7 @@
import { tool } from "@langchain/core/tools";
import z from "zod";
import { DBModel } from "../../../../models/index.js";
import { escapeRegex } from "./utils.js";
const hospitalInfoSetTool = tool(
async ({ hospitalName, section, action, content, guides, entry, entryName, updatedBy }) => {
@@ -9,8 +10,10 @@ const hospitalInfoSetTool = tool(
return { success: false, error: "hospitalName 不能为空" };
}
// 定位医院:名称必须唯一命中
const orgs = await DBModel.Organization.find({ name: { $regex: hospitalName, $options: "i" } }).exec();
// 定位医院:名称必须唯一命中;转义正则元字符,避免非法表达式与 ReDoS
const orgs = await DBModel.Organization.find({
name: { $regex: escapeRegex(hospitalName), $options: "i" },
}).exec();
if (orgs.length === 0) {
return { success: false, error: `未找到名称包含「${hospitalName}」的机构,请确认医院名称后重试` };
}