INNER CODE UNIT · Python

_db_row_to_prediction

cmu-sei/GHOSTS · experimental/grms/grms/main.py:202

def _db_row_to_prediction(row: dict) -> SavedPrediction:
    """Reconstruct a SavedPrediction from a database row."""
    score = None
    if row.get("overall_score") is not None:
        dims = json.loads(row["dimensions_json"]) if row.get("dimensions_json") else []
        score = PredictionScore(
            overall_score=row["overall_score"],
            escalation_score=row.get("escalation_score"),
            action_type_score=row.get("action_type_score"),
            tone_score=row.get("tone_score"),
            dimensions=[ScoreDimension(**d) for d in dims],
            scored_at=datetime.fromisoformat(row["scored_at"]) if row.get("scored_at") else datetime.utcnow(),
        )

    known_outcome = None
    if row.get("known_outcome_json"):
        known_outcome = KnownOutcome.model_validate_json(row["known_outcome_json"])

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…