调整了agent
This commit is contained in:
@@ -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}」的机构,请确认医院名称后重试` };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user