From 263d4d8e65c0c2e0d6e6f9a7388382d5c3106c0b Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 27 Feb 2024 22:21:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Gemini=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E8=AF=8D=E5=8F=98=E9=87=8F=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/config.example.ini | 4 ++-- services/translate.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data/config.example.ini b/data/config.example.ini index 2f1f3ec..9ae384f 100644 --- a/data/config.example.ini +++ b/data/config.example.ini @@ -172,7 +172,7 @@ model_code = models/gemini-1.0-pro # 提示词 prompt = As an advanced translation software, your role is to provide accurate translations that respect the original content's meaning and tone. - Ensure that texts between brackets "[]" are kept untranslated. + Ensure that texts between square brackets "[]" are kept untranslated. Aim to deliver the translated text in a polite and gentle tone, as per the preferences of the audience.\n\n Below are some examples to guide you:\n\n Input1:\n来拉(莱拉)设置一下吧\nOutput1:\nライラちゃん、設定してみましょうか\n\n @@ -186,7 +186,7 @@ prompt = As an advanced translation software, your role is to provide accurate t source language.\n\n Now, proceed with the translation of the following Chinese comment text into Japanese, ensuring accuracy and preservation of the original message:\n - Input:\n{{original_text}}\nOutput ONLY:\n + Input:\n{original_text}\nOutput ONLY:\n # 温度,用于控制令牌选择的随机性,较低的温度适合需要更具确定性或不够开放的回答的提示,而较高的温度可以产生更加多样化或更具创意的结果 temperature = 0.4 diff --git a/services/translate.py b/services/translate.py index 6c09ec4..f1a9f88 100644 --- a/services/translate.py +++ b/services/translate.py @@ -730,7 +730,7 @@ class GeminiTranslate(TranslateProvider): return self._cool_down_timer_handle is None and super().is_available async def _do_translate(self, text) -> Optional[str]: - input_text = self._prompt.replace('{{original_text}}', text) + input_text = self._prompt.format(original_text=text) self._body['contents'][0]['parts'][0]['text'] = input_text try: async with utils.request.http_session.post(