增加附件机制

This commit is contained in:
xunbu
2025-08-28 17:35:12 +08:00
parent 40012b59b4
commit f4aeca05fc
20 changed files with 96 additions and 32 deletions

View File

@@ -37,8 +37,8 @@ class MDTranslator(AiTranslator):
with MDMaskUrisContext(document):
chunks: list[str] = split_markdown_text(document.content.decode(), self.chunk_size)
if self.glossary_agent:
glossary_dict = self.glossary_agent.send_segments(chunks, self.chunk_size)
self.translate_agent.update_glossary_dict(glossary_dict)
self.glossary_dict_gen = self.glossary_agent.send_segments(chunks, self.chunk_size)
self.translate_agent.update_glossary_dict(self.glossary_dict_gen)
self.logger.info(f"markdown分为{len(chunks)}")
result: list[str] = self.translate_agent.send_chunks(chunks)
content = join_markdown_texts(result)
@@ -56,8 +56,8 @@ class MDTranslator(AiTranslator):
chunks: list[str] = split_markdown_text(document.content.decode(), self.chunk_size)
if self.glossary_agent:
glossary_dict = await self.glossary_agent.send_segments_async(chunks, self.chunk_size)
self.translate_agent.update_glossary_dict(glossary_dict)
self.glossary_dict_gen = await self.glossary_agent.send_segments_async(chunks, self.chunk_size)
self.translate_agent.update_glossary_dict(self.glossary_dict_gen)
self.logger.info(f"markdown分为{len(chunks)}")
result: list[str] = await self.translate_agent.send_chunks_async(chunks)