优化Gemini提示词变量格式

This commit is contained in:
John Smith 2024-02-27 22:21:09 +08:00
parent 0d7f847dc8
commit 263d4d8e65
2 changed files with 3 additions and 3 deletions

View File

@ -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 prompt = As an advanced translation software, your role is to provide accurate translations that respect
the original content's meaning and tone. 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 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 Below are some examples to guide you:\n\n
Input1:\n来拉(莱拉)设置一下吧\nOutput1:\nライラちゃん、設定してみましょうか\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 source language.\n\n
Now, proceed with the translation of the following Chinese comment text into Japanese, ensuring accuracy Now, proceed with the translation of the following Chinese comment text into Japanese, ensuring accuracy
and preservation of the original message:\n and preservation of the original message:\n
Input:\n{{original_text}}\nOutput ONLY:\n Input:\n{original_text}\nOutput ONLY:\n
# 温度,用于控制令牌选择的随机性,较低的温度适合需要更具确定性或不够开放的回答的提示,而较高的温度可以产生更加多样化或更具创意的结果 # 温度,用于控制令牌选择的随机性,较低的温度适合需要更具确定性或不够开放的回答的提示,而较高的温度可以产生更加多样化或更具创意的结果
temperature = 0.4 temperature = 0.4

View File

@ -730,7 +730,7 @@ class GeminiTranslate(TranslateProvider):
return self._cool_down_timer_handle is None and super().is_available return self._cool_down_timer_handle is None and super().is_available
async def _do_translate(self, text) -> Optional[str]: 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 self._body['contents'][0]['parts'][0]['text'] = input_text
try: try:
async with utils.request.http_session.post( async with utils.request.http_session.post(