File size: 796 Bytes
2567e7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from typing import Optional
from fastapi import APIRouter, Query
from app.core.security import UserContext
from app.core.data_store import DataStore
from app.agent.proactive_detector import ProactiveIssueDetector

router = APIRouter(prefix="/api/proactive", tags=["Proactive Intelligence"])

data_store_instance: Optional[DataStore] = None

@router.get("/insights")
async def get_proactive_insights(
    account_id: Optional[str] = Query(None),
    is_internal: bool = Query(True),
    role: str = Query("operations_lead")
):
    """Returns proactive alerts, SLA breaches, ticket clusters, and carrier delays."""
    ctx = UserContext(account_id=account_id, is_internal=is_internal, role=role)
    detector = ProactiveIssueDetector(data_store_instance)
    return detector.detect_all_issues(ctx)