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

@@ -309,49 +309,3 @@ def bump_reply_plan_for_background_voice(
likely_chit_chat=plan.likely_chit_chat,
information_rich=plan.information_rich,
)
# 向后兼容:旧名与旧签名(仅测试或外部引用)
def compute_reply_length_strategy(
user_message_len: int,
*,
likely_new_detail: bool,
likely_chit_chat: bool,
settings: "Settings",
) -> ReplyPlan:
"""已弃用:请用 compute_reply_plan(user_message, ...)。保留供过渡期。"""
# 无法还原 information_rich按旧逻辑近似
n = max(0, int(user_message_len))
max_segments = int(settings.chat_interview_max_segments)
if n <= _LEN_BRIEF_MAX:
mode = ReplyLengthMode.brief
elif n < _LEN_LONG_MIN:
mode = ReplyLengthMode.standard
else:
if likely_chit_chat:
mode = ReplyLengthMode.standard
elif likely_new_detail:
mode = ReplyLengthMode.expanded
else:
mode = ReplyLengthMode.standard
return _plan_from_mode(
mode,
max_segments=max_segments,
settings=settings,
background_voice=None,
likely_new=likely_new_detail,
likely_chit=likely_chit_chat,
info_rich=False,
)
def bump_reply_length_strategy_for_background_voice(
plan: ReplyPlan,
*,
background_voice: str | None,
settings: "Settings",
) -> ReplyPlan:
"""旧名兼容。"""
return bump_reply_plan_for_background_voice(
plan, background_voice=background_voice, settings=settings
)