Files
api_health/agent/infra/tools/db/hospital_info_get.js
T
2026-09-09 17:36:45 +08:00

33 lines
941 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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("医院 idMongoDB ObjectId,来自 hospital_info_list"),
}),
}
);
export { hospitalInfoGetTool };