22 lines
586 B
Python
22 lines
586 B
Python
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
|
|
class ReviewError(RuntimeError):
|
|
pass
|
|
|
|
|
|
def normalize_review_result(result: Any) -> dict[str, Any]:
|
|
if not isinstance(result, dict):
|
|
raise ReviewError(f"Invalid review result type: {type(result)!r}")
|
|
if "findings" not in result:
|
|
result["findings"] = []
|
|
if "summary" not in result:
|
|
result["summary"] = "No summary returned."
|
|
if "verdict" not in result:
|
|
result["verdict"] = "has_issues"
|
|
if "confidence" not in result:
|
|
result["confidence"] = 0.5
|
|
return result
|