fix: 修复回忆录celery异常

This commit is contained in:
yangshilin
2026-03-19 14:02:21 +08:00
parent 4c75c6f4f4
commit 8dc47d200b

View File

@@ -387,10 +387,13 @@ def _save_narrative_to_sections(db: Session, chapter, narrative: str, title: str
def _placeholder_for_segment(seg: dict, order_idx: int) -> dict | None:
ph = seg.get("placeholder_info")
if ph and ph.get("placeholder") and ph.get("description"):
# 确保有 indexbuild_initial_image_assets 依赖此字段
if "index" not in ph:
ph = {**ph, "index": order_idx}
return ph
content = (seg.get("content") or "").strip()
desc = (content[:50] + "") if len(content) > 50 else (content or "章节配图")
return {"placeholder": f"{{{{{{{{IMAGE:{desc}}}}}}}}}", "description": desc}
return {"placeholder": f"{{{{{{{{IMAGE:{desc}}}}}}}}}", "description": desc, "index": order_idx}
# 按顺序创建 section每 3 个 section 对应 1 张配图
for i, seg in enumerate(segments):