From b16ab75dca09845e9d759b352e8db71f24d54f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Mon, 7 Oct 2024 19:13:45 +0800 Subject: [PATCH] fix --- .../LunaTranslator/translator/sakura.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/LunaTranslator/LunaTranslator/translator/sakura.py b/LunaTranslator/LunaTranslator/translator/sakura.py index baa19438..e2639c05 100644 --- a/LunaTranslator/LunaTranslator/translator/sakura.py +++ b/LunaTranslator/LunaTranslator/translator/sakura.py @@ -104,13 +104,16 @@ class TS(basetrans): ] self._gpt_common_parse_context(messages, self.context, contextnum) gpt_dict_raw_text = self.make_gpt_dict_text(gpt_dict) - content = ( - "根据以下术语表(可以为空):\n" - + gpt_dict_raw_text - + "\n" - + "将下面的日文文本根据对应关系和备注翻译成中文:" - + query - ) + if gpt_dict_raw_text: + content = ( + "根据以下术语表(可以为空):\n" + + gpt_dict_raw_text + + "\n" + + "将下面的日文文本根据对应关系和备注翻译成中文:" + + query + ) + else: + content = "将下面的日文文本翻译成中文:" + query messages.append({"role": "user", "content": content}) return messages