Files
unredact/tests/test_llm_validate.py
Alex-GilbertandClaude Opus 4.6 672bdc3223 fix: batch LLM validation, stream results, improve scoring prompt
- Batch candidates in groups of 50 (was 200) to avoid output token
  truncation that caused all-zero scores
- Stream scored results via SSE as each batch completes instead of
  waiting for all batches to finish
- Include solve_id in done event so validate works when results fit
  in a single page
- Rewrite prompt to judge sentence coherence ("does it make sense")
  rather than word predictability ("is it expected")
- Frontend inserts results in score-sorted order as they arrive

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-23 21:17:00 -06:00

38 lines
1.2 KiB
Python

"""Tests for LLM solve result validation."""
import pytest
from unredact.pipeline.llm_validate import build_validation_prompt, SCORE_TOOL
class TestBuildValidationPrompt:
def test_basic_prompt_structure(self):
candidates = ["Smith", "house", "running"]
prompt = build_validation_prompt(
left_context="Dear Mr.",
right_context=", we are writing",
candidates=candidates,
)
assert "Dear Mr." in prompt
assert ", we are writing" in prompt
assert "1. Smith" in prompt
assert "2. house" in prompt
assert "3. running" in prompt
assert "_____" in prompt
def test_empty_context(self):
prompt = build_validation_prompt(
left_context="",
right_context="",
candidates=["word"],
)
assert "1. word" in prompt
def test_score_tool_schema(self):
assert SCORE_TOOL["name"] == "score_candidates"
schema = SCORE_TOOL["input_schema"]
assert "scores" in schema["properties"]
items = schema["properties"]["scores"]["items"]
assert "index" in items["properties"]
assert "score" in items["properties"]