- 新增 utterance_substance:短时/应答/元话语可跳过记忆检索、阶段 LLM 与资料抽取 LLM;可配置 - 输入归一化:LLM 模式默认仅语音/ASR;配置项写入 .env.example - Memoir Phase1:可选 batch LLM 一次性抽取+分类(失败回退逐段);Extraction 空槽位时阶段与 current_stage 对齐,prompt 约束收紧 - 叙事与忠实度:narrative_safety、证据重叠/场合锚点、标题 slots 与履历短语 grounded;fidelity 解析失败 fail-open 可配置 - 章节管线:锁 TTL 上调、锁竞争 Celery 重试、Phase2 immediate singleflight 等;story_pipeline_sync / chapter_compose / memoir_tasks 联动 - Memory:compaction / repo / summarizer / evidence 小修;事实 FTS 未命中是否回退最近事实可配置 - 新增 memoir_pipeline_trace;补充 memoir_reliability 文档与多项回归/门控测试
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
"""访谈轮次「实质内容」启发式(阶段 LLM / 记忆检索门控)。"""
|
|
|
|
import pytest
|
|
|
|
from app.agents.chat import utterance_substance as us
|
|
|
|
|
|
@pytest.fixture
|
|
def heuristic_on(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setattr(
|
|
"app.agents.chat.utterance_substance.settings.chat_substantive_heuristic_enabled",
|
|
True,
|
|
)
|
|
monkeypatch.setattr(
|
|
"app.agents.chat.utterance_substance.settings.chat_substantive_min_chars",
|
|
12,
|
|
)
|
|
|
|
|
|
def test_substantive_long_sentence(heuristic_on: None) -> None:
|
|
assert us.should_run_chat_stage_memory_heavy_work(
|
|
"我在下乡插队时住在生产队仓库里,印象最深的是冬天的早晨。"
|
|
)
|
|
|
|
|
|
def test_non_substantive_ack(heuristic_on: None) -> None:
|
|
assert not us.should_run_chat_stage_memory_heavy_work("嗯")
|
|
assert not us.should_run_chat_stage_memory_heavy_work("对对")
|
|
|
|
|
|
def test_non_substantive_meta_process(heuristic_on: None) -> None:
|
|
assert not us.should_run_chat_stage_memory_heavy_work("我回忆起了许多快忘的细节")
|
|
|
|
|
|
def test_five_char_short_substantive_not_skipped(heuristic_on: None) -> None:
|
|
"""五字短句未命中应答/元话语时不应被当成非实质(评审:旧 >=6 会误杀)。"""
|
|
assert len("我进了工厂") == 5
|
|
assert us.should_run_chat_stage_memory_heavy_work("我进了工厂")
|
|
|
|
|
|
def test_heuristic_disabled_always_true(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setattr(
|
|
"app.agents.chat.utterance_substance.settings.chat_substantive_heuristic_enabled",
|
|
False,
|
|
)
|
|
assert us.should_run_chat_stage_memory_heavy_work("嗯")
|