53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
import { tool } from "langchain"
|
|
|
|
/**
|
|
* 特定日期日历工具
|
|
* 提供指定日期的日历信息
|
|
*/
|
|
export const getLunarCalendarInfoTool = tool(
|
|
async ({ year, month, day }) => {
|
|
try {
|
|
const date = new Date(year, month - 1, day)
|
|
|
|
if (isNaN(date.getTime())) {
|
|
return JSON.stringify({ error: '无效的日期' }, null, 2)
|
|
}
|
|
|
|
// 获取农历信息
|
|
const lunarInfo = {}
|
|
|
|
return JSON.stringify(lunarInfo, null, 2)
|
|
} catch (error) {
|
|
console.error('Error in date calendar tool:', error)
|
|
return JSON.stringify({ error: error.message }, null, 2)
|
|
}
|
|
},
|
|
{
|
|
name: "get_lunar_calendar_info",
|
|
description: "获取指定日期的日历信息,包括农历信息、老黄历、当年生肖、今日宜忌、喜神方位、财神方位、今日节气、今日节日等",
|
|
schema: {
|
|
type: "object",
|
|
properties: {
|
|
year: {
|
|
type: "number",
|
|
description: "年份",
|
|
minimum: 1900,
|
|
maximum: 2100
|
|
},
|
|
month: {
|
|
type: "number",
|
|
description: "月份",
|
|
minimum: 1,
|
|
maximum: 12
|
|
},
|
|
day: {
|
|
type: "number",
|
|
description: "日期",
|
|
minimum: 1,
|
|
maximum: 31
|
|
}
|
|
},
|
|
required: ["year", "month", "day"]
|
|
}
|
|
}
|
|
) |