tmp
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { tool } from "@langchain/core/tools";
|
||||
import z from "zod";
|
||||
import { DBModel } from "../../../../models/index.js";
|
||||
|
||||
const hospitalInfoGetTool = tool(
|
||||
async ({ hospitalId }) => {
|
||||
try {
|
||||
if (!hospitalId) {
|
||||
return { success: false, error: "hospitalId 不能为空" };
|
||||
}
|
||||
|
||||
const org = await DBModel.Organization.findById(hospitalId).lean();
|
||||
if (!org) {
|
||||
return { success: false, error: `未找到 id 为「${hospitalId}」的机构` };
|
||||
}
|
||||
|
||||
return { success: true, data: org };
|
||||
} catch (error) {
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "hospital_info_get",
|
||||
description:
|
||||
"根据医院 id 获取医院完整信息。id 可通过 hospital_info_list 获取。",
|
||||
schema: z.object({
|
||||
hospitalId: z.string().describe("医院 id(MongoDB ObjectId,来自 hospital_info_list)"),
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
export { hospitalInfoGetTool };
|
||||
Reference in New Issue
Block a user