fix(writer): 正文语言须与章节标题一致(模板日文则输出日文)

This commit is contained in:
lhl
2026-08-14 00:12:51 +08:00
parent 4da5f7087d
commit 48a9624723
3 changed files with 12 additions and 2 deletions
+2 -1
View File
@@ -107,4 +107,5 @@
| 2026-08-13 23:11 | Agent 实现 | 接通真实 LLM 引擎工厂(P5-T10 门禁接线):新增 inference/factory.pyorchestrator/qa_loop 接入,脚本校验适配,补工厂测试 | src/genesis/inference/factory.py; src/genesis/writer/orchestrator.py; src/genesis/qa/qa_loop.py; scripts/run_phase5_slice.py; tests/test_inference_factory.py | hy3-free |
| 2026-08-13 23:20 | 测试验证 | P5-T10 引擎工厂接线:补 engine=None 委托工厂测试(orchestrator/qa_loop),全量 296 passed / 99.04% | tests/test_phase5_writer_orchestrator.py; tests/test_phase5_qa_loop.py | hy3-free |
| 2026-08-13 23:35 | 测试验证 | P5-T10 门禁诊断:修复 WriterGenerationError 吞掉底层 LLM 错误(如 401 详情),补透传测试 | src/genesis/writer/writer_agent.py; tests/test_phase5_writer_agent.py | hy3-free |
| 2026-08-13 23:50 | Agent 实现 | 修复 HttpLLMClient 在同步门禁中多次 asyncio.run 复用已关闭事件循环致 Event loop is closedchat 改为每次调用新建 client(保留 async with 协议)| src/genesis/inference/client.py | hy3-free |
| 2026-08-13 23:50 | Agent 实现 | 修复 HttpLLMClient 在同步门禁中多次 asyncio.run 复用已关闭事件循环致 Event loop is closedchat 改为每次调用新建 client(保留 async with 协议)| src/genesis/inference/client.py | hy3-free |
| 2026-08-13 23:58 | Agent 实现 | P5-T10 语言对齐:WRITER_PROMPT_TEMPLATE 增加「正文语言须与章节标题一致」约束(模板日文则输出日文)| src/genesis/writer/writer_agent.py; tests/test_phase5_writer_agent.py | hy3-free |
+4 -1
View File
@@ -22,7 +22,10 @@ WRITER_PROMPT_TEMPLATE = (
"设计规则:\n{{design_rules}}\n"
"模板样式:\n{{template_styles}}\n"
"参考资料:\n{{source}}\n"
"请输出符合 schema 的章节内容 JSON。"
"请输出符合 schema 的章节内容 JSON。\n"
"【语言约束】章节正文(所有 block 的 text 字段)所使用的自然语言,"
"必须与章节标题「{{title}}」所用语言保持一致:标题为日文则用日文撰写,"
"为中文则用中文撰写,依此类推。"
)
CHAPTER_OUTPUT_SCHEMA = {
+6
View File
@@ -54,6 +54,12 @@ def test_generate_chapter_success():
assert content.blocks and content.blocks[0].type == "paragraph"
def test_prompt_template_enforces_title_language():
# 语言约束:正文需与章节标题语言一致(模板为日文时输出日文)
assert "语言约束" in WRITER_PROMPT_TEMPLATE
assert "{{title}}" in WRITER_PROMPT_TEMPLATE
def test_generate_chapter_retries():
class Boom(FakeEngine):
def chat_structured(self, *, session_id, prompt, variables, schema, retry_count=2):