63 lines
1.9 KiB
Python
63 lines
1.9 KiB
Python
"""大周天演化候选 prompt 构建纯函数测试。"""
|
|
|
|
from app.modules.big_cycle.prompts import (
|
|
EvaluationSnapshot,
|
|
build_evolution_extraction_messages,
|
|
)
|
|
|
|
|
|
def _snapshot() -> EvaluationSnapshot:
|
|
return EvaluationSnapshot(
|
|
character_id="character_x",
|
|
memory_count=25,
|
|
recent_memories=[("喜欢简洁回答", "用户偏好简洁"), ("来自北京", "用户所在地")],
|
|
personality_summary="身份:魂镜;表达风格:温和",
|
|
world_entity_count=3,
|
|
conclusion="近期互动偏技术话题,表达可更简洁",
|
|
)
|
|
|
|
|
|
def test_messages_return_system_user_pair() -> None:
|
|
system, user = build_evolution_extraction_messages(_snapshot())
|
|
assert isinstance(system, str) and isinstance(user, str)
|
|
assert system and user
|
|
|
|
|
|
def test_system_describes_contract_fields() -> None:
|
|
system, _ = build_evolution_extraction_messages(_snapshot())
|
|
for token in (
|
|
"type",
|
|
"level",
|
|
"scope",
|
|
"proposal",
|
|
"delta",
|
|
"auto_apply_allowed",
|
|
):
|
|
assert token in system
|
|
|
|
|
|
def test_system_lists_evolution_types() -> None:
|
|
system, _ = build_evolution_extraction_messages(_snapshot())
|
|
for t in ("personality", "procedural", "tool_strategy", "memory"):
|
|
assert t in system
|
|
|
|
|
|
def test_system_states_level_semantics() -> None:
|
|
system, _ = build_evolution_extraction_messages(_snapshot())
|
|
assert "L4" in system
|
|
|
|
|
|
def test_user_includes_snapshot_signals() -> None:
|
|
_, user = build_evolution_extraction_messages(_snapshot())
|
|
assert "喜欢简洁回答" in user
|
|
assert "身份:魂镜" in user
|
|
assert "25" in user
|
|
|
|
|
|
def test_user_handles_empty_personality() -> None:
|
|
snap = _snapshot()
|
|
snap.personality_summary = ""
|
|
_, user = build_evolution_extraction_messages(snap)
|
|
assert isinstance(user, str)
|
|
assert len(user) > 0
|