feat: 生成图片提示词agent结构封装

This commit is contained in:
yangshilin
2026-03-19 10:43:34 +08:00
parent 4a1d6f0dcc
commit c21cda3e78
7 changed files with 131 additions and 12 deletions

View File

@@ -42,6 +42,7 @@ from app.features.memoir.memoir_images.parser import (
)
import hashlib
from app.core.dependencies import get_image_generator
from app.agents.image_prompt import ImagePromptOrchestrator
from app.features.memoir.memoir_images.prompting import MemoirImagePromptService
from app.features.memoir.memoir_images.schema import (
completed_image_assets,
@@ -883,7 +884,7 @@ def generate_chapter_images(self, chapter_id: str):
logger.info("章节补图跳过: chapter=%s, reason=locked", chapter_id)
return {"status": "locked"}
prompt_service = MemoirImagePromptService(_get_llm(), settings)
prompt_orchestrator = ImagePromptOrchestrator(_get_llm(), settings)
image_generator = get_image_generator()
storage = TencentCosStorageService.from_env()
logger.info(
@@ -922,7 +923,7 @@ def generate_chapter_images(self, chapter_id: str):
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]
prompt_data = prompt_service.build_cover_prompt(
prompt_data = prompt_orchestrator.build_cover_prompt(
chapter_title=chapter.title,
chapter_category=chapter.category or "",
context_excerpt=context_excerpt,
@@ -985,7 +986,7 @@ def generate_chapter_images(self, chapter_id: str):
try:
context_lines = (section.content or "").strip().split("\n")[:5]
context_excerpt = " ".join(context_lines)[:200]
prompt_data = prompt_service.build_prompt(
prompt_data = prompt_orchestrator.build_prompt(
chapter_title=chapter.title,
chapter_category=chapter.category or "",
description=current_item.get("description", ""),