feat(memoir): 回忆录分段两阶段管线(Phase1 分类 / Phase2 叙事)与配置、测试

This commit is contained in:
Kevin
2026-04-02 16:37:14 +08:00
parent 3ae39838c0
commit 6b930808a3
27 changed files with 1550 additions and 430 deletions

View File

@@ -8,6 +8,7 @@ from __future__ import annotations
import json
from typing import Any, Dict, Optional
from app.agents.stage_constants import CHAPTER_CATEGORIES
from app.agents.memoir.prompts import (
get_creative_title_json_prompt,
get_narrative_json_prompt,
@@ -34,7 +35,7 @@ class NarrativeAgent:
) -> str:
"""生成创意标题。若无 LLM 则返回默认标题"""
if not llm:
return f"{stage} 回忆"
return f"{CHAPTER_CATEGORIES.get(stage, stage)} 回忆"
try:
prompt = get_creative_title_json_prompt(
stage=stage,
@@ -53,10 +54,10 @@ class NarrativeAgent:
title = (data.get("title") or "").strip() if isinstance(data, dict) else ""
if title:
return title.strip('"')
return f"{stage} 回忆"
return f"{CHAPTER_CATEGORIES.get(stage, stage)} 回忆"
except Exception as e:
logger.warning("NarrativeAgent 生成标题失败: {}", e)
return f"{stage} 回忆"
return f"{CHAPTER_CATEGORIES.get(stage, stage)} 回忆"
def generate_narrative(
self,