# @File: backend/schemas/whatsapp_insights.py
# @Desc: Pydantic I/O models for the AI insights endpoint on the
#        WhatsApp analytics dashboard. The shapes mirror what the
#        insights service returns; we keep a few fields ``Any`` to
#        stay forward-compatible with additional LLM fields.
from __future__ import annotations

from typing import Any, Dict, List, Optional

from pydantic import BaseModel


class InsightWarning(BaseModel):
    campaign_id: Optional[int] = None
    campaign_name: str
    severity: str  # "low" | "medium" | "high"
    reason: str


class InsightsOut(BaseModel):
    summary: str
    trends: List[str]
    recommendations: List[str]
    warnings: List[InsightWarning]
    model: str
    fallback: bool
    range: Dict[str, Any] = {}
    kpis: Dict[str, Any] = {}