feat(api): 叙事 prompt、职业上下文、读路径章节、WS 解耦与错误脱敏
- 回忆录:事实边界补充允许清单;传记文体示例与 JSON 叙事要求对齐 - default 职业提示 occupation_context;cadre/military 退休语境 - GET 章节读路径零写入,prepare_chapter_read_view + markdown_for_response - 文本归一抽到 core/text_normalize;移除弃用 reply 策略与 recompose_chapters_for_story - ConversationService:WS 连接/用户段落/结束对话;对外错误固定文案 - 测试:HTTP 脱敏契约、章节读视图、occupation 与 background_voice
This commit is contained in:
@@ -33,7 +33,7 @@ from app.features.memoir.memoir_images.settings import MemoirImageSettings
|
||||
from app.features.memoir.models import Chapter
|
||||
from app.features.memoir.narrative_to_markdown import narrative_to_markdown
|
||||
from app.features.memoir.oral_normalize import (
|
||||
apply_oral_normalization_rules,
|
||||
apply_oral_rules,
|
||||
normalize_oral_for_memoir,
|
||||
)
|
||||
from app.features.memoir.repo import (
|
||||
@@ -63,7 +63,7 @@ def _route_segment_texts(category_segments: list) -> list[tuple[str, str]]:
|
||||
and (settings.memoir_oral_normalize_mode or "rules").strip().lower()
|
||||
!= "off"
|
||||
):
|
||||
t = apply_oral_normalization_rules(raw)
|
||||
t = apply_oral_rules(raw)
|
||||
else:
|
||||
t = raw
|
||||
out.append((str(seg.id), t))
|
||||
@@ -312,6 +312,7 @@ def _run_batch_plan_writes(
|
||||
llm: Any,
|
||||
narrative_agent: NarrativeAgent,
|
||||
background_voice: str = "default",
|
||||
occupation: str = "",
|
||||
) -> set[str]:
|
||||
dispatch_ids: set[str] = set()
|
||||
max_chars = int(settings.story_append_max_canonical_chars)
|
||||
@@ -362,6 +363,7 @@ def _run_batch_plan_writes(
|
||||
birth_year=user_birth_year,
|
||||
llm=llm,
|
||||
background_voice=background_voice,
|
||||
occupation=occupation,
|
||||
)
|
||||
json_invalid = False
|
||||
s0 = (raw_gen or "").strip()
|
||||
@@ -461,6 +463,7 @@ def run_story_pipeline_for_category_batch(
|
||||
user_birth_year: int | None,
|
||||
llm: Any,
|
||||
background_voice: str = "default",
|
||||
occupation: str = "",
|
||||
) -> tuple[Chapter | None, bool, set[str]]:
|
||||
"""
|
||||
返回 (chapter, needs_cover_enqueue, story_ids_to_dispatch_after_commit)。
|
||||
@@ -589,6 +592,7 @@ def run_story_pipeline_for_category_batch(
|
||||
llm=llm,
|
||||
narrative_agent=narrative_agent,
|
||||
background_voice=background_voice,
|
||||
occupation=occupation,
|
||||
)
|
||||
else:
|
||||
route = route_agent.decide(
|
||||
@@ -636,6 +640,7 @@ def run_story_pipeline_for_category_batch(
|
||||
birth_year=user_birth_year,
|
||||
llm=llm,
|
||||
background_voice=background_voice,
|
||||
occupation=occupation,
|
||||
)
|
||||
json_invalid = False
|
||||
s0 = (raw_gen or "").strip()
|
||||
|
||||
Reference in New Issue
Block a user