import { tool } from "langchain" /** * 年份节日列表工具 * 查询给定年份节日所在日期列表 */ export const getYearHolidaysTool = tool( async ({ year }) => { try { // 简化实现,返回基本节日信息 const holidays = [ { date: `${year}-01-01`, name: '元旦' }, { date: `${year}-02-14`, name: '情人节' }, { date: `${year}-05-01`, name: '劳动节' }, { date: `${year}-06-01`, name: '儿童节' }, { date: `${year}-10-01`, name: '国庆节' } ] return JSON.stringify({ year, holidays }, null, 2) } catch (error) { console.error('Error in year holidays tool:', error) return JSON.stringify({ error: error.message }, null, 2) } }, { name: "get_year_holidays", description: "查询给定年份节日所在日期列表", schema: { type: "object", properties: { year: { type: "number", description: "年份", minimum: 1900, maximum: 2100 } }, required: ["year"] } } )