From 81caf99fb55f3d429718390d2384af2693ada3d6 Mon Sep 17 00:00:00 2001 From: Caspian Zhao Date: Wed, 13 Dec 2023 19:49:36 +0000 Subject: [PATCH] fix: Skip translation if the content is null. (#1136) --- src/app/api/translate-note/route.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/api/translate-note/route.ts b/src/app/api/translate-note/route.ts index 586a89af..bf7244c4 100644 --- a/src/app/api/translate-note/route.ts +++ b/src/app/api/translate-note/route.ts @@ -88,8 +88,15 @@ const getOriginalTranslation = async ( translationChains.set(`${modelSize}_${targetLang}`, chain) } - const t = await chain.call({ text: title }) - const c = await chain.call({ text: content }) + const t = + String(title).trim().length === 0 + ? { text: "" } + : await chain.call({ text: title }) + + const c = + String(content).trim().length === 0 + ? { text: "" } + : await chain.call({ text: content }) console.timeEnd(`fetching translation ${cid}, ${targetLang}`)