优化了agent
This commit is contained in:
@@ -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)
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user