优化了agent

This commit is contained in:
lik
2026-10-31 18:51:20 +08:00
parent ab584c5fa8
commit 02d57f82dc
22 changed files with 193 additions and 155 deletions
+3 -2
View File
@@ -1,6 +1,7 @@
import { tool } from "@langchain/core/tools"
import { z } from "zod"
import { Solar } from "lunar-javascript"
import logger from "../../../../utils/logger.js"
/**
* 日历工具
@@ -75,7 +76,7 @@ async function getBeijingNow() {
success: true
}
} catch (error) {
console.warn(`获取网络时间失败,使用本机时间: ${error.message}`)
logger.warn(`获取网络时间失败,使用本机时间: ${error.message}`)
const now = new Date()
return {
...getBeijingDateParts(now),
@@ -118,7 +119,7 @@ export const getCalendarInfoTool = tool(
const solar = Solar.fromYmd(now.year, now.month, now.day)
return JSON.stringify({ now, ...buildDayInfo(solar) }, null, 2)
} catch (error) {
console.error("Error in calendar tool:", error)
logger.error("Error in calendar tool:", error)
return JSON.stringify({ error: error.message }, null, 2)
}
},