feat: 更新byteMonitor以清理翻译结果并添加错误日志,新增测试用例
This commit is contained in:
parent
32396aecf1
commit
bfd9aec103
@ -6,6 +6,7 @@ import pbClient from "../db/pbClient"
|
|||||||
import { Context } from "../types"
|
import { Context } from "../types"
|
||||||
import { genContextManually } from "../utils/genContext"
|
import { genContextManually } from "../utils/genContext"
|
||||||
import llm from "../utils/llm"
|
import llm from "../utils/llm"
|
||||||
|
import { cleanLLMRes } from "../utils/llm/base"
|
||||||
|
|
||||||
await initAppConfig()
|
await initAppConfig()
|
||||||
|
|
||||||
@ -26,8 +27,11 @@ const translateTextList = async (textList: string[], requestId: string) => {
|
|||||||
1,
|
1,
|
||||||
true
|
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<string, string> = {}
|
const translatedMap: Record<string, string> = {}
|
||||||
textList.forEach((text, index) => {
|
textList.forEach((text, index) => {
|
||||||
@ -227,6 +231,7 @@ const byteMonitor = async () => {
|
|||||||
"byteMonitor 更新"
|
"byteMonitor 更新"
|
||||||
)
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
const errorMessage = `byteMonitor error: ${error}`
|
const errorMessage = `byteMonitor error: ${error}`
|
||||||
logger.error(errorMessage)
|
logger.error(errorMessage)
|
||||||
} finally {
|
} finally {
|
||||||
|
6
test/schedule/byteMonitor.ts
Normal file
6
test/schedule/byteMonitor.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import initAppConfig from "../../constant/config"
|
||||||
|
import byteMonitor from "../../schedule/byteMonitor"
|
||||||
|
|
||||||
|
await initAppConfig()
|
||||||
|
|
||||||
|
await byteMonitor()
|
Loading…
x
Reference in New Issue
Block a user