feat(ai写作): 自带大纲/会商及研究模板等前后端改动
提交工作区中 AI 写作(表单/时间线/历史/上下文/流式 hook/类型)、 研究模板配置页、lead_agent、researcher/graph/state 及 gateway/config 的进行中改动。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
d2c76100f2
commit
e9c8d1cea2
18 files changed
+287
-50
No files matched your search
+44
-5
@@ -399,6 +399,22 @@ async def researcher_node(state: AIWritingState, config: RunnableConfig) -> dict
|
||||
def _emit(message: str) -> None:
|
||||
writer({"type": "research_progress", "message": message})
|
||||
|
||||
# 跳过素材收集:用户在初始表单勾选「不收集素材,直接用通用知识写作」。
|
||||
# 仅在**首次**进入(无任何 pause 干预 = intervention 为空)时短路,避免后续
|
||||
# 「补充检索 / 按输入追加」等再入研究节点时被误跳过。直接产出空素材包、强制
|
||||
# loose 写作模式(无素材可严格依据),并跳过素材确认暂停点直奔大纲规划。
|
||||
if state.get("skip_research") and not intervention:
|
||||
empty_pkg = MaterialPackage(keywords=[], materials=[], summary="用户选择不收集素材,直接用通用知识写作")
|
||||
return {
|
||||
"material_package": empty_pkg,
|
||||
"writing_mode": "loose",
|
||||
"status": "writing_outline",
|
||||
"progress_events": [
|
||||
{"type": "step_start", "agent_name": researcher_label, "message": "已跳过素材收集,直接用通用知识写作"},
|
||||
{"type": "materials_ready", "agent_name": researcher_label, "message": "未收集素材(通用知识写作)"},
|
||||
],
|
||||
}
|
||||
|
||||
# Step 1: 提取关键词
|
||||
kw_result: dict = {} # 走"用户输入 / 追加"分支时跳过 LLM 调用,notice 拼接需要兜底值
|
||||
if is_user_query_search:
|
||||
@@ -856,13 +872,36 @@ async def researcher_node(state: AIWritingState, config: RunnableConfig) -> dict
|
||||
step_start_msg = f"通用检索(技能编排 {len(skill_steps)} 步):{', '.join(keywords[:3])}"
|
||||
else:
|
||||
step_start_msg = f"搜索关键词:{', '.join(keywords[:3])}"
|
||||
|
||||
progress_events: list[dict] = [
|
||||
{"type": "step_start", "agent_name": researcher_label, "message": step_start_msg},
|
||||
*notices,
|
||||
{"type": "materials_ready", "agent_name": researcher_label, "message": summary},
|
||||
]
|
||||
extra_updates: dict = {}
|
||||
# 用户自带大纲:在「搜集素材」阶段顺便解析大纲并把素材归类到各章节,
|
||||
# 从而跳过 writer_outline 的大纲生成步(见 graph after_material_pause 路由)。
|
||||
# 补充检索(is_supplement)直接回写作、沿用原大纲,不在此整理。
|
||||
if not is_supplement and (state.get("user_outline_raw") or "").strip():
|
||||
from .writer_outline import build_user_outline_with_materials
|
||||
|
||||
try:
|
||||
organized = await build_user_outline_with_materials(state, config, pkg)
|
||||
except Exception:
|
||||
logger.warning("researcher: 整理用户大纲失败(非致命),回退到大纲生成步", exc_info=True)
|
||||
organized = None
|
||||
if organized:
|
||||
extra_updates["current_outline"] = organized
|
||||
progress_events.append({
|
||||
"type": "outline_ready",
|
||||
"agent_name": researcher_label,
|
||||
"message": f"已按你提供的大纲整理素材,共 {len(organized.get('sections', []))} 个章节",
|
||||
})
|
||||
|
||||
return {
|
||||
"material_package": pkg,
|
||||
# 补充检索:直接回写作(沿用原大纲);常规检索:进入素材确认暂停点
|
||||
"status": "writing_draft" if is_supplement else "awaiting_material_confirm",
|
||||
"progress_events": [
|
||||
{"type": "step_start", "agent_name": researcher_label, "message": step_start_msg},
|
||||
*notices,
|
||||
{"type": "materials_ready", "agent_name": researcher_label, "message": summary},
|
||||
],
|
||||
**extra_updates,
|
||||
"progress_events": progress_events,
|
||||
}
|
||||
Reference in new issue
Block a user