1. 建立问题库大纲,对应每个人生阶段槽位
2. 鼓励使用更生活化的交流语言共情与总结
3. 降低评审模型可能发生截断的概率
4. 成稿质量维度强化情感表达和上下文连贯性
This commit is contained in:
yangshilin
2026-04-09 15:32:35 +08:00
parent 064ad2161d
commit e1341c6d18
49 changed files with 938 additions and 271 deletions

View File

@@ -6,13 +6,19 @@ from app.agents.chat.interview_state_hints import (
apply_duplicate_question_guard,
extract_scene_cues,
)
from app.agents.state_schema import KnownFact, MemoirStateSchema, PersonaThread, default_slots
from app.agents.state_schema import (
KnownFact,
MemoirStateSchema,
PersonaThread,
default_slots,
)
from app.agents.chat.helpers import format_history_string
from app.agents.chat.personas import normalize_interview_persona
from app.agents.chat.prompts_conversation import (
get_guided_conversation_prompt,
get_opening_prompt,
)
from app.agents.chat.slot_question_bank import SLOT_QUESTION_OUTLINES
def test_guided_prompt_does_not_embed_raw_user_message_in_system_text():
@@ -37,6 +43,96 @@ def test_guided_prompt_does_not_embed_raw_user_message_in_system_text():
assert "__USER_SECRET_PROFILE__" in p2
def test_guided_prompt_injects_slot_question_outline_for_empty_slots():
p = get_guided_conversation_prompt(
current_stage="childhood",
empty_slots=["place", "people"],
filled_slots={"emotion": "挺开心的"},
detected_user_stage="childhood",
user_profile_context="",
persona="default",
)
assert "本阶段问题大纲" in p
assert "叙述槽" in p or "采集目标" in p
assert "成长的地方" in p
assert "重要的人" in p
def test_guided_prompt_emotion_priority_over_outline():
p = get_guided_conversation_prompt(
current_stage="education",
empty_slots=["school"],
filled_slots={},
detected_user_stage="education",
user_profile_context="",
persona="default",
)
assert "情绪" in p and "大纲" in p
def test_guided_prompt_includes_memoir_quality_rubric_hints():
p = get_guided_conversation_prompt(
current_stage="career",
empty_slots=["growth"],
filled_slots={"job": "做过工程师"},
detected_user_stage="career",
user_profile_context="",
persona="default",
)
assert "成稿质量导向" in p
assert "真实性与覆盖" in p
assert "出版就绪度" in p
def test_guided_prompt_follow_immersion_whitespace_style_examples():
p = get_guided_conversation_prompt(
current_stage="belief",
empty_slots=["value"],
filled_slots={},
detected_user_stage="belief",
user_profile_context="",
persona="default",
)
assert "跟随" in p and "沉浸" in p
assert "留白" in p
assert "风格参考" in p
assert "这让我想起" in p
def test_guided_prompt_narrative_weave_and_transition():
p = get_guided_conversation_prompt(
current_stage="childhood",
empty_slots=["place"],
filled_slots={},
detected_user_stage="childhood",
user_profile_context="",
persona="default",
)
assert "编织" in p or "内在线" in p
assert "通感" in p or "比喻" in p
assert "下面我们聊聊" in p
def test_guided_prompt_host_tone_and_context_forward():
p = get_guided_conversation_prompt(
current_stage="career",
empty_slots=["job"],
filled_slots={},
detected_user_stage="career",
user_profile_context="",
persona="default",
)
assert "主持" in p or "播报" in p
assert "上下文" in p or "既定事实" in p
assert "行为" in p and "影响" in p
def test_education_and_family_change_outlines_differ():
edu = SLOT_QUESTION_OUTLINES[("education", "change")]
fam = SLOT_QUESTION_OUTLINES[("family", "change")]
assert edu[0] != fam[0]
def test_guided_prompt_mentions_empathy_and_scene_strategy():
p = get_guided_conversation_prompt(
current_stage="childhood",
@@ -146,7 +242,9 @@ def test_guided_prompt_includes_known_facts_persona_threads_and_recent_questions
user_profile_context="",
persona="default",
known_facts=[
KnownFact(label="本轮新信息", value="我后来去了瑞士读书", stage="education"),
KnownFact(
label="本轮新信息", value="我后来去了瑞士读书", stage="education"
),
],
persona_threads=[
PersonaThread(trait="执着坚持", evidence="为了训练咬牙坚持了很多年"),
@@ -211,6 +309,7 @@ def test_extract_scene_cues_empty_for_abstract_text():
def test_default_persona_now_has_tone_hint():
from app.agents.chat.personas import get_interview_persona_tone_hint
hint = get_interview_persona_tone_hint("default")
assert hint
assert "画面" in hint or "细节" in hint