From 1db85daed133ed98b1c14b6cc071c6c11d20bf79 Mon Sep 17 00:00:00 2001 From: xushengfeng Date: Mon, 9 Sep 2024 18:37:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=20=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E6=8F=90=E7=A4=BAai=20key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/translate/tool.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/translate/tool.js b/lib/translate/tool.js index c09602223b..83733cc7ed 100644 --- a/lib/translate/tool.js +++ b/lib/translate/tool.js @@ -145,6 +145,8 @@ if (uuid) { if (ai) { const tt = getToTranslate(ai); console.log(tt); + if (!process.env.gpt) + throw new Error("Please set GPT_TOKEN: export gpt=sk-"); fetch("https://api.chatanywhere.tech/v1/chat/completions", { method: "POST", headers: { @@ -200,9 +202,6 @@ if (ai) { const id = source[i]; out[id] = v[id] || l[id] || ""; } - fs.writeFileSync( - `${ai}.json`, - `${JSON.stringify(out, null, 4)}\n`, - ); + fs.writeFileSync(`${ai}.json`, `${JSON.stringify(out, null, 4)}\n`); }); }