42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
|
|
"""
|
|||
|
|
Chapter 封面意图 — 从本章 stories 或章节内容聚合生成封面 prompt。
|
|||
|
|
|
|||
|
|
封面不回写进 chapter 正文 markdown,绑定到 chapters.cover_asset_id。
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
from __future__ import annotations
|
|||
|
|
|
|||
|
|
|
|||
|
|
def aggregate_cover_prompt_from_stories(
|
|||
|
|
stories: list,
|
|||
|
|
*,
|
|||
|
|
chapter_title: str = "",
|
|||
|
|
chapter_category: str = "",
|
|||
|
|
) -> str:
|
|||
|
|
"""
|
|||
|
|
从本章 stories 聚合封面 prompt。
|
|||
|
|
人物、地点、时间、情绪、时代背景。
|
|||
|
|
"""
|
|||
|
|
parts = []
|
|||
|
|
if chapter_title:
|
|||
|
|
parts.append(chapter_title)
|
|||
|
|
if chapter_category:
|
|||
|
|
parts.append(chapter_category)
|
|||
|
|
for s in (stories or [])[:5]:
|
|||
|
|
title = getattr(s, "title", None) or (
|
|||
|
|
s.get("title") if isinstance(s, dict) else None
|
|||
|
|
)
|
|||
|
|
stage = getattr(s, "stage", None) or (
|
|||
|
|
s.get("stage") if isinstance(s, dict) else None
|
|||
|
|
)
|
|||
|
|
summary = getattr(s, "summary", None) or (
|
|||
|
|
s.get("summary") if isinstance(s, dict) else None
|
|||
|
|
)
|
|||
|
|
if title:
|
|||
|
|
parts.append(title)
|
|||
|
|
if stage:
|
|||
|
|
parts.append(stage)
|
|||
|
|
if summary:
|
|||
|
|
parts.append((summary or "")[:100])
|
|||
|
|
return ",".join(p for p in parts if p) or "人生回忆录章节"
|