diff --git a/services/extractor/event_classifier.py b/services/extractor/event_classifier.py index c5df5ab..17bc4a4 100644 --- a/services/extractor/event_classifier.py +++ b/services/extractor/event_classifier.py @@ -293,6 +293,12 @@ def _parse_classification_response( cleaned = _repair_json(cleaned) data = json.loads(cleaned) + # Model sometimes wraps the object in a list — unwrap it + if isinstance(data, list) and len(data) == 1 and isinstance(data[0], dict): + data = data[0] + if not isinstance(data, dict): + raise ValueError(f"Expected a JSON object, got {type(data).__name__}") + confidence = data.get("confidence", 0.5) if isinstance(confidence, (int, float)): confidence = max(0.0, min(1.0, float(confidence)))