From bfd9aec1036c1a552025dbe07529b18d7ab2ca4b Mon Sep 17 00:00:00 2001 From: zhaoyingbo Date: Mon, 24 Feb 2025 08:49:08 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0byteMonitor=E4=BB=A5?= =?UTF-8?q?=E6=B8=85=E7=90=86=E7=BF=BB=E8=AF=91=E7=BB=93=E6=9E=9C=E5=B9=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=94=99=E8=AF=AF=E6=97=A5=E5=BF=97=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- schedule/byteMonitor.ts | 7 ++++++- test/schedule/byteMonitor.ts | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 test/schedule/byteMonitor.ts diff --git a/schedule/byteMonitor.ts b/schedule/byteMonitor.ts index b05ae98..7a87573 100644 --- a/schedule/byteMonitor.ts +++ b/schedule/byteMonitor.ts @@ -6,6 +6,7 @@ import pbClient from "../db/pbClient" import { Context } from "../types" import { genContextManually } from "../utils/genContext" import llm from "../utils/llm" +import { cleanLLMRes } from "../utils/llm/base" await initAppConfig() @@ -26,8 +27,11 @@ const translateTextList = async (textList: string[], requestId: string) => { 1, true ) + console.log("🚀 ~ translateTextList ~ translatedTexts:", translatedTexts) - const translatedList = JSON.parse(translatedTexts as string) as string[] + const translatedList = JSON.parse( + cleanLLMRes(translatedTexts as string) + ) as string[] const translatedMap: Record = {} textList.forEach((text, index) => { @@ -227,6 +231,7 @@ const byteMonitor = async () => { "byteMonitor 更新" ) } catch (error) { + console.error(error) const errorMessage = `byteMonitor error: ${error}` logger.error(errorMessage) } finally { diff --git a/test/schedule/byteMonitor.ts b/test/schedule/byteMonitor.ts new file mode 100644 index 0000000..4a965d7 --- /dev/null +++ b/test/schedule/byteMonitor.ts @@ -0,0 +1,6 @@ +import initAppConfig from "../../constant/config" +import byteMonitor from "../../schedule/byteMonitor" + +await initAppConfig() + +await byteMonitor()