增加txt不分段选项
This commit is contained in:
@@ -183,7 +183,6 @@ class SegmentsTranslateAgent(Agent):
|
||||
def send_segments(self, segments: list[str], chunk_size: int) -> list[str]:
|
||||
indexed_originals, chunks, merged_indices_list = segments2json_chunks(segments, chunk_size)
|
||||
prompts = [generate_prompt(json.dumps(chunk, ensure_ascii=False, indent=0), self.to_lang) for chunk in chunks]
|
||||
|
||||
translated_chunks = super().send_prompts(prompts=prompts, json_format=self.json_format,
|
||||
pre_send_handler=self._pre_send_handler,
|
||||
result_handler=self._result_handler,
|
||||
@@ -227,7 +226,6 @@ class SegmentsTranslateAgent(Agent):
|
||||
pre_send_handler=self._pre_send_handler,
|
||||
result_handler=self._result_handler,
|
||||
error_result_handler=self._error_result_handler)
|
||||
|
||||
indexed_translated = indexed_originals.copy()
|
||||
for chunk in translated_chunks:
|
||||
try:
|
||||
|
||||
@@ -469,9 +469,9 @@ class TextWorkflowParams(BaseWorkflowParams):
|
||||
"\n",
|
||||
description="当 insert_mode 为 'append' 或 'prepend' 时,用于分隔原文和译文的分隔符。",
|
||||
)
|
||||
segment_mode: Literal["line", "paragraph"] = Field(
|
||||
segment_mode: Literal["line", "paragraph", "none"] = Field(
|
||||
"line",
|
||||
description="分段模式。'line':按行分段(每行独立翻译),'paragraph':按段落分段(连续非空行合并为段落)。",
|
||||
description="分段模式。'line':按行分段(每行独立翻译),'paragraph':按段落分段(连续非空行合并为段落),'none':不分段(全文视为一个段落)。",
|
||||
)
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -24,11 +24,12 @@ class TXTTranslatorConfig(AiTranslatorConfig):
|
||||
separator (str):
|
||||
在 "append" 或 "prepend" 模式下,用于分隔原文和译文的字符串。
|
||||
默认为换行符 "\n"。
|
||||
segment_mode (Literal["line", "paragraph"]):
|
||||
segment_mode (Literal["line", "paragraph", "none"]):
|
||||
分段模式。
|
||||
- "line": 按行分段(每行独立翻译)
|
||||
- "paragraph": 按段落分段(连续非空行合并为段落)
|
||||
默认为 "paragraph"。
|
||||
- "none": 不分段(全文视为一个段落)
|
||||
默认为 "line"。
|
||||
"""
|
||||
insert_mode: Literal["replace", "append", "prepend"] = "replace"
|
||||
separator: str = "\n"
|
||||
|
||||
Reference in New Issue
Block a user