fix: degrade distractor pool gracefully on malformed VLM response

This commit is contained in:
2026-07-14 14:11:13 -04:00
parent 8a54055d02
commit d0194f5840
2 changed files with 18 additions and 5 deletions
+8
View File
@@ -55,6 +55,14 @@ class _Material:
source_nodes = ("n1",)
@pytest.mark.asyncio
async def test_generate_pool_degrades_on_malformed_response():
from app.question_gen.distractor_selector import _generate_pool
vlm = _FakeVLM(['["not", "a", "dict"]']) # 顶层是 list 不是 dict
out = await _generate_pool(vlm, "?", "", _Material(), 4, session_id="s")
assert out == []
@pytest.mark.asyncio
async def test_build_grounded_options_happy_path():
pool = '{"distractors": ["", "", "", ""]}'