降低缺键概率

This commit is contained in:
xunbu
2025-09-06 21:08:19 +08:00
parent 000e82a383
commit c4755dabd3
2 changed files with 13 additions and 12 deletions

View File

@@ -191,7 +191,7 @@ class Agent:
should_retry = True
# 专门捕获部分翻译错误(软错误)
except PartialAgentResultError as e:
# print(f"【测试】\nprompt:\n{prompt}\nresp:\n{result}")
print(f"【测试】\nprompt:\n{prompt}\nresp:\n{result}")
self.logger.error(f"收到部分返回结果,将尝试重试: {e}")
current_partial_result = e.partial_result
should_retry = True

View File

@@ -39,31 +39,32 @@ class SegmentsTranslateAgent(Agent):
- For personal names and proper nouns, use the most commonly used words for translation.
- For special tags or other non-translatable elements (like codes, brand names, specific jargon), keep them in their original form.
- If a segment is already in the target language({config.to_lang}), keep it as is.
- Do not merge multiple segment translations into one translation.
- (very important) All keys that appear in the input JSON must exist in the output JSON.
# Output
- The translated sequence of segments, represented as JSON text (note: not a code block). The keys are the segment IDs, and the values are the translated segments.
- The response must be a JSON object(indent=0) with the following structure:
- The response must be a JSON object with the following structure:
{{
"<segment_id>": "<translation>"
}}
- (very important) The segment IDs in the output must exactly match those in the input. And all segment IDs in input must appear in the output.
- All keys that appear in the input JSON must exist in the output JSON.
# Example(Assuming the target language is Chinese in the example, {config.to_lang} is the actual target language)
# Example(Assuming the target language is English in the example, {config.to_lang} is the actual target language)
## Input
{{
"10": "Tom say:\"hello\"",
"11": "apple",
"12": true,
"13": "false",
"14": null
}}
## Correct Output
{{
"10": "汤姆说:“你好”",
"11": "苹果",
"12": true,
"13": "错误",
"14": null
}}
## Correct Output
{{
"10": "Tom say:\"hello\"",
"11": "apple",
"12": true,
"13": "false",
"14": null
}}
"""
self.custom_prompt = config.custom_prompt
if config.custom_prompt: