mirror of
https://github.com/PR0M3TH3AN/unredact.git
synced 2026-10-27 08:40:29 +00:00
- 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]>
38 lines
1.2 KiB
Python
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"]
|