from typesafe_sdk import Choice, Noul, Score, TypeSafeClient client = TypeSafeClient() TRIAGE_QUESTIONS = { "category": Choice( instructions="Primary technical domain of the incident", criteria={ "network": "Connectivity, DNS, load balancers, VPN", "compute": "Hosts, containers, capacity, crashes", "data": "Databases, storage, replication, data quality", "identity": "SSO, IAM, certificates, access", "application": "Application errors and regressions", }, ), "priority": Score( instructions="Priority based on business impact and urgency", criteria=["P4 - minimal", "P3 - moderate", "P2 - high", "P1 - critical"], ), "security_relevant": Noul( instructions="The incident may involve a security breach or unauthorised access", ), "customer_facing": Noul( instructions="External customers are currently affected", ), } def triage(incident_text: str) -> dict: answers = client.system_one(state=incident_text, questions=TRIAGE_QUESTIONS).answers return { "category": answers["category"].choice, "category_confidence": answers["category"].confidence, "priority": int(answers["priority"].score), # index into the ordered criteria "security_relevant": answers["security_relevant"].noul >= 0.30, # low bar: missing one is costly "customer_facing": answers["customer_facing"].noul >= 0.50, }