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:
Kevin
2026-04-01 11:49:33 +08:00
parent a5473e8fe2
commit 53d9e003af
28 changed files with 598 additions and 397 deletions

View File

@@ -203,6 +203,7 @@ class ChatOrchestrator:
user_profile_context = ""
background_voice = "default"
occupation = ""
if user:
user_profile_context = format_user_profile_context(
birth_year=user.birth_year,
@@ -211,6 +212,7 @@ class ChatOrchestrator:
occupation=user.occupation,
)
background_voice = infer_background_voice(user.occupation)
occupation = user.occupation or ""
memory_evidence_text = await _fetch_interview_memory_evidence(
db, user_id, normalized_user_message
@@ -225,6 +227,7 @@ class ChatOrchestrator:
memory_evidence_text=memory_evidence_text,
background_voice=background_voice,
normalized_user_message=normalized_user_message,
occupation=occupation,
)
if agent_summary_enabled():
logger.info(
@@ -297,6 +300,7 @@ class ChatOrchestrator:
memory_evidence_text: str = "",
background_voice: str = "default",
normalized_user_message: str | None = None,
occupation: str = "",
) -> AgentChatTurn:
"""委托 InterviewAgent 生成访谈回复(持久化由调用方负责)。"""
return await self.interview_agent.generate_response_with_state(
@@ -308,6 +312,7 @@ class ChatOrchestrator:
memory_evidence_text=memory_evidence_text,
background_voice=background_voice,
normalized_user_message=normalized_user_message,
occupation=occupation,
)
def detect_user_stage(self, user_message: str) -> str:
@@ -320,6 +325,7 @@ class ChatOrchestrator:
memoir_state: MemoirStateSchema,
user_profile_context: str = "",
background_voice: str = "default",
occupation: str = "",
) -> List[str]:
"""
委托 InterviewAgent 生成访谈开场白(持久化由调用方 ConversationHistoryStore 负责)。
@@ -329,4 +335,5 @@ class ChatOrchestrator:
memoir_state=memoir_state,
user_profile_context=user_profile_context,
background_voice=background_voice,
occupation=occupation,
)