feat/调整tts音色,调整封面图prompt,修复对话页输入框显示逻辑,待验证封面图生成功能
This commit is contained in:
@@ -342,7 +342,9 @@ def _save_narrative_to_sections(db: Session, chapter, narrative: str, title: str
|
||||
)
|
||||
db.add(sec)
|
||||
db.flush()
|
||||
if img_settings.enabled:
|
||||
# 封面:仅当 section 配图 > 3 时创建
|
||||
section_image_count = sum(1 for s in existing_sections if s.image_id)
|
||||
if img_settings.enabled and section_image_count > 3:
|
||||
stmt_cover = (
|
||||
select(MemoirImage)
|
||||
.where(
|
||||
@@ -381,7 +383,7 @@ def _save_narrative_to_sections(db: Session, chapter, narrative: str, title: str
|
||||
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):
|
||||
@@ -416,8 +418,11 @@ def _save_narrative_to_sections(db: Session, chapter, narrative: str, title: str
|
||||
sec.image_id = mi.id
|
||||
db.flush()
|
||||
|
||||
# 封面图:若无则创建 pending MemoirImage(section_id=None, order_index=0)
|
||||
if img_settings.enabled:
|
||||
# 封面图:仅当 section 配图 > 3 时创建 pending MemoirImage(section_id=None, order_index=0)
|
||||
existing_with_img = sum(1 for s in existing_sections if s.image_id)
|
||||
new_with_img = sum(1 for i in range(len(segments)) if _should_have_image(order_base + i))
|
||||
section_image_count = existing_with_img + new_with_img
|
||||
if img_settings.enabled and section_image_count > 3:
|
||||
stmt_cover = (
|
||||
select(MemoirImage)
|
||||
.where(
|
||||
@@ -1020,8 +1025,10 @@ def generate_chapter_images(self, chapter_id: str):
|
||||
db.commit()
|
||||
try:
|
||||
sections_ordered = sorted(sections, key=lambda s: getattr(s, "order_index", 0))
|
||||
first_content = (sections_ordered[0].content or "").strip() if sections_ordered else ""
|
||||
context_excerpt = " ".join(first_content.split("\n")[:5])[:200]
|
||||
full_content = "\n\n".join(
|
||||
(s.content or "").strip() for s in sections_ordered if (s.content or "").strip()
|
||||
)
|
||||
context_excerpt = full_content[:1500] if full_content else ""
|
||||
prompt_data = prompt_service.build_cover_prompt(
|
||||
chapter_title=chapter.title,
|
||||
chapter_category=chapter.category or "",
|
||||
|
||||
Reference in New Issue
Block a user