调整了agent
This commit is contained in:
@@ -2,6 +2,7 @@ import { tool } from "@langchain/core/tools";
|
||||
import z from "zod";
|
||||
import mongoose from "mongoose";
|
||||
import { DBModel } from "../../../../models/index.js";
|
||||
import { escapeRegex } from "./utils.js";
|
||||
|
||||
const healthProfileQueryTool = tool(
|
||||
async ({ profileId, userId, name, mobile, page = 1, pageSize = 20 }) => {
|
||||
@@ -28,8 +29,7 @@ const healthProfileQueryTool = tool(
|
||||
}
|
||||
if (name) {
|
||||
// 转义正则特殊字符,避免查询报错或 ReDoS;姓名支持中文、全拼、拼音首字母匹配
|
||||
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
const re = { $regex: escaped, $options: "i" };
|
||||
const re = { $regex: escapeRegex(name), $options: "i" };
|
||||
filter.$or = [{ "profile.name": re }, { "profile.pinyin": re }, { "profile.pinyinFL": re }];
|
||||
}
|
||||
if (mobile) {
|
||||
|
||||
Reference in New Issue
Block a user