Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/fast_mlsirm/llm_judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def _criteria(values: Iterable[JudgeCriterion | Mapping[str, Any]]) -> tuple[Jud
weight=value.get("weight", 1.0),
)
else:
raise TypeError("criteria must contain JudgeCriterion or mapping values")
raise ValueError("criteria must contain JudgeCriterion or mapping values")
normalized.append(criterion)
if not 1 <= len(normalized) <= MAX_JUDGE_CRITERIA:
raise ValueError(f"criteria must contain 1..{MAX_JUDGE_CRITERIA} values")
Expand Down
11 changes: 11 additions & 0 deletions tests/test_llm_judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ def __float__(self):
assert _HookedFloat.invoked is False


def test_judge_criteria_reject_non_contract_values_with_value_error() -> None:
"""Arbitrary criterion elements must fail through the stable benign error contract."""
with pytest.raises(ValueError, match="JudgeCriterion or mapping"):
ContextualOrchestratorJudge(_FakeOrchestrator(_payload())).judge(
task="task",
answer="answer",
criteria=[object()],
)


if __name__ == "__main__":
test_judge_uses_contextual_orchestrator_route_and_reports_usage()
test_judge_rejects_malformed_decisions_and_derives_acceptance()
Expand All @@ -279,4 +289,5 @@ def __float__(self):
test_category_judgment_rejects_non_integral_categories()
test_judge_rejects_missing_or_malformed_model_fields()
test_judge_criteria_reject_invalid_runtime_types()
test_judge_criteria_reject_non_contract_values_with_value_error()
print("ok")
Loading