From 5085da7e12611b78a314e48c76b199f89b5ea5a3 Mon Sep 17 00:00:00 2001 From: zhaoyingbo Date: Sat, 25 Jan 2025 09:08:11 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=8D=E6=9E=84pbClient=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=80=BB=E8=BE=91=E4=B8=BA=E7=8B=AC=E7=AB=8B=E5=87=BD?= =?UTF-8?q?=E6=95=B0=EF=BC=9B=E6=B7=BB=E5=8A=A0=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=AF=8F=E5=B0=8F=E6=97=B6=E6=89=A7=E8=A1=8C=E7=99=BB?= =?UTF-8?q?=E5=BD=95=EF=BC=9B=E6=96=B0=E5=A2=9E=E6=84=8F=E5=9B=BE=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E6=B5=8B=E8=AF=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/pbClient.ts | 9 ++++++--- schedule/index.ts | 4 ++++ test/llm/intentRecognition.ts | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 test/llm/intentRecognition.ts diff --git a/db/pbClient.ts b/db/pbClient.ts index f6a2c9a..2356814 100644 --- a/db/pbClient.ts +++ b/db/pbClient.ts @@ -4,8 +4,11 @@ const pbClient = new PocketBase(Bun.env.PB_URL) pbClient.autoCancellation(false) -await pbClient - .collection("_superusers") - .authWithPassword(Bun.env.PB_USER, Bun.env.PB_PASS) +export const loginPbClient = async () => + await pbClient + .collection("_superusers") + .authWithPassword(Bun.env.PB_USER, Bun.env.PB_PASS) + +await loginPbClient() export default pbClient diff --git a/schedule/index.ts b/schedule/index.ts index 2f8e23f..abcaa43 100644 --- a/schedule/index.ts +++ b/schedule/index.ts @@ -1,6 +1,7 @@ import schedule from "node-schedule" import report from "../controller/groupAgent/report" +import { loginPbClient } from "../db/pbClient" import fmMonitor from "./fmMonitor" import sendZhongNotify from "./zhongNotify" @@ -16,4 +17,7 @@ export const initSchedule = async () => { // 定时任务,每5分钟执行一次 schedule.scheduleJob("*/5 * * * *", fmMonitor) + + // 定时任务,每小时执行一次 + schedule.scheduleJob("0 * * * *", loginPbClient) } diff --git a/test/llm/intentRecognition.ts b/test/llm/intentRecognition.ts new file mode 100644 index 0000000..711b005 --- /dev/null +++ b/test/llm/intentRecognition.ts @@ -0,0 +1,15 @@ +import initAppConfig from "../../constant/config" +import llm from "../../utils/llm" + +await initAppConfig() + +const res = await llm.invoke( + "intentRecognition", + { + userInput: "你是干嘛的", + time: new Date().toLocaleString("zh-CN", { timeZone: "Asia/Shanghai" }), + }, + "test" +) + +console.log(res)