66 lines
2.0 KiB
Python
66 lines
2.0 KiB
Python
|
|
"""interview_turn_plan:轮次模式与主槽选择(服务端硬编排)。"""
|
|||
|
|
|
|||
|
|
from app.agents.chat.interview_turn_plan import (
|
|||
|
|
extract_anchor_snippet,
|
|||
|
|
plan_interview_turn,
|
|||
|
|
primary_empty_slot,
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_primary_empty_slot_order():
|
|||
|
|
assert primary_empty_slot("childhood", ["emotion", "place"]) == "place"
|
|||
|
|
assert primary_empty_slot("childhood", ["emotion"]) == "emotion"
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_extract_anchor_snippet_prefers_memory():
|
|||
|
|
mem = "摘录的一段记忆\n\n[场景氛围提示"
|
|||
|
|
assert "摘录的一段记忆" in extract_anchor_snippet(
|
|||
|
|
memory_evidence_text=mem, user_message="用户说很长一句" * 3
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_plan_memoir_push():
|
|||
|
|
p = plan_interview_turn(
|
|||
|
|
current_stage="childhood",
|
|||
|
|
empty_slots=["place", "people"],
|
|||
|
|
normalized_user_message="我小时候住在河边,夏天常去玩水。",
|
|||
|
|
memory_evidence_text="",
|
|||
|
|
stage_switched_this_turn=False,
|
|||
|
|
)
|
|||
|
|
assert p.mode == "memoir_push"
|
|||
|
|
assert p.anchor_slot_key == "place"
|
|||
|
|
assert p.anchor_snippet
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_plan_emotion_first():
|
|||
|
|
p = plan_interview_turn(
|
|||
|
|
current_stage="childhood",
|
|||
|
|
empty_slots=["place"],
|
|||
|
|
normalized_user_message="想起来还是很难受,忍不住想哭。",
|
|||
|
|
memory_evidence_text="",
|
|||
|
|
stage_switched_this_turn=False,
|
|||
|
|
)
|
|||
|
|
assert p.mode == "emotion_first"
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_plan_follow_on_stage_switch():
|
|||
|
|
p = plan_interview_turn(
|
|||
|
|
current_stage="education",
|
|||
|
|
empty_slots=["school", "city"],
|
|||
|
|
normalized_user_message="后来我去省城读中学了。",
|
|||
|
|
memory_evidence_text="",
|
|||
|
|
stage_switched_this_turn=True,
|
|||
|
|
)
|
|||
|
|
assert p.mode == "follow_user_only"
|
|||
|
|
|
|||
|
|
|
|||
|
|
def test_plan_follow_when_no_empty_slots():
|
|||
|
|
p = plan_interview_turn(
|
|||
|
|
current_stage="childhood",
|
|||
|
|
empty_slots=[],
|
|||
|
|
normalized_user_message="嗯。",
|
|||
|
|
memory_evidence_text="",
|
|||
|
|
stage_switched_this_turn=False,
|
|||
|
|
)
|
|||
|
|
assert p.mode == "follow_user_only"
|