diff --git a/docutranslate/agents/agent.py b/docutranslate/agents/agent.py index 8e4b03a..19bf369 100644 --- a/docutranslate/agents/agent.py +++ b/docutranslate/agents/agent.py @@ -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 diff --git a/docutranslate/agents/segments_agent.py b/docutranslate/agents/segments_agent.py index 11a9308..153efa7 100644 --- a/docutranslate/agents/segments_agent.py +++ b/docutranslate/agents/segments_agent.py @@ -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: {{ "": "" }} - (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: