|
@@ -763,22 +763,27 @@ class OutlineGenerator:
|
|
|
title = chapter_node.get("title", "")
|
|
title = chapter_node.get("title", "")
|
|
|
code = chapter_node.get("code", "")
|
|
code = chapter_node.get("code", "")
|
|
|
children = chapter_node.get("children", [])
|
|
children = chapter_node.get("children", [])
|
|
|
-
|
|
|
|
|
|
|
+ template_content = chapter_node.get("template_content", "无")
|
|
|
logger.info(f"[章节生成] trace_id: {trace_id}, 开始生成 {current_index} {title}")
|
|
logger.info(f"[章节生成] trace_id: {trace_id}, 开始生成 {current_index} {title}")
|
|
|
|
|
|
|
|
# 检查终止信号 - 在章节生成开始前
|
|
# 检查终止信号 - 在章节生成开始前
|
|
|
if await self._check_terminate_by_trace_id(trace_id):
|
|
if await self._check_terminate_by_trace_id(trace_id):
|
|
|
logger.warning(f"[章节生成] trace_id: {trace_id}, 检测到终止信号,停止生成 {current_index} {title}")
|
|
logger.warning(f"[章节生成] trace_id: {trace_id}, 检测到终止信号,停止生成 {current_index} {title}")
|
|
|
raise asyncio.CancelledError(f"任务被终止: {current_index} {title}")
|
|
raise asyncio.CancelledError(f"任务被终止: {current_index} {title}")
|
|
|
-
|
|
|
|
|
- # 1. 生成当前章节的 content
|
|
|
|
|
- chapter_content = await self._generate_chapter_content(
|
|
|
|
|
- trace_id=trace_id,
|
|
|
|
|
- project_info=project_info,
|
|
|
|
|
- chapter_title=title,
|
|
|
|
|
- chapter_code=code,
|
|
|
|
|
- level=level
|
|
|
|
|
- )
|
|
|
|
|
|
|
+
|
|
|
|
|
+ # 1. 生成当前章节的 content,有模版内容ai生成,没有模版内容则直接返回空字符串
|
|
|
|
|
+ chapter_content = ''
|
|
|
|
|
+ if template_content == '' or template_content == '无':
|
|
|
|
|
+ chapter_content = ''
|
|
|
|
|
+ else:
|
|
|
|
|
+ chapter_content = await self._generate_chapter_content(
|
|
|
|
|
+ trace_id=trace_id,
|
|
|
|
|
+ project_info=project_info,
|
|
|
|
|
+ chapter_title=title,
|
|
|
|
|
+ chapter_code=code,
|
|
|
|
|
+ level=level,
|
|
|
|
|
+ template_content=template_content
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
# 检查终止信号 - 在 LLM 调用后
|
|
# 检查终止信号 - 在 LLM 调用后
|
|
|
if await self._check_terminate_by_trace_id(trace_id):
|
|
if await self._check_terminate_by_trace_id(trace_id):
|
|
@@ -956,7 +961,8 @@ class OutlineGenerator:
|
|
|
project_info: Dict[str, Any],
|
|
project_info: Dict[str, Any],
|
|
|
chapter_title: str,
|
|
chapter_title: str,
|
|
|
chapter_code: str,
|
|
chapter_code: str,
|
|
|
- level: int
|
|
|
|
|
|
|
+ level: int,
|
|
|
|
|
+ template_content: str = ""
|
|
|
) -> str:
|
|
) -> str:
|
|
|
"""
|
|
"""
|
|
|
生成章节内容
|
|
生成章节内容
|
|
@@ -990,17 +996,25 @@ class OutlineGenerator:
|
|
|
# 构建提示词
|
|
# 构建提示词
|
|
|
prompt = f"""请为施工方案生成【{chapter_title}】章节的内容。
|
|
prompt = f"""请为施工方案生成【{chapter_title}】章节的内容。
|
|
|
|
|
|
|
|
|
|
+【项目信息】
|
|
|
项目名称:{project_name}
|
|
项目名称:{project_name}
|
|
|
章节编号:{chapter_code}
|
|
章节编号:{chapter_code}
|
|
|
章节层级:第{level}级
|
|
章节层级:第{level}级
|
|
|
|
|
+{writing_requirements}
|
|
|
|
|
+
|
|
|
|
|
+【核心指令】(必须逐条严格遵守,违反任一条视为生成失败)
|
|
|
|
|
+1. 空即留空:若【参考模板内容】中对应部分为空、无、未标注或仅为占位符,该部分输出必须严格留空(仅保留换行),严禁任何脑补、扩写、补充或格式转换。
|
|
|
|
|
+2. 结构像素级锁定:100% 原样保留模板的标题层级、段落顺序、编号体系、表格与图片占位符。仅替换占位符/括号内的通用表述为本项目实际数据。严禁增删段落、合并/拆分表格行列、改变列表层级、调整原文顺序。
|
|
|
|
|
+3. 表格强规则:
|
|
|
|
|
+ ✅ 模板中已有的表格,必须使用标准 Markdown 语法完整输出,表头名称、列数、列顺序、行数量绝对禁止修改。
|
|
|
|
|
+ ❌ 模板中无表格的部分,输出中严禁出现任何表格(严禁将参数列表、工艺流程、材料清单、施工步骤等转换为表格形式)。
|
|
|
|
|
+4. 零冗余输出:不添加任何方案标题、前言、落款、编号前缀或解释性文字。严格对齐模板原始层级与换行位置。
|
|
|
|
|
+5. 图片占位符:完整保留原始占位标记,并在其后紧邻位置标注“(此处放置XX示意图)”,不得删除或替换为其他描述。
|
|
|
|
|
|
|
|
-{writing_requirements}通用要求:
|
|
|
|
|
-1. 内容专业、准确,符合公路桥梁施工规范
|
|
|
|
|
-2. 语言简洁明了,条理清晰
|
|
|
|
|
-3. 根据实际情况生成合理的施工方案内容
|
|
|
|
|
-4. 字数控制在200-500字之间
|
|
|
|
|
|
|
+【参考模板内容】
|
|
|
|
|
+{template_content}
|
|
|
|
|
|
|
|
-请直接输出章节内容,不要包含标题。"""
|
|
|
|
|
|
|
+请直接输出该章节正文内容,无需任何解释、前言或结尾、标题。"""
|
|
|
|
|
|
|
|
try:
|
|
try:
|
|
|
content = await self._call_llm(
|
|
content = await self._call_llm(
|