from transformers import AutoModelForCausalLM, AutoTokenizerimport torch, json, re tok = AutoTokenizer.from_pretrained("enterprise-ai-lab/sevclassifier-jev-style-1.5b")model = AutoModelForCausalLM.from_pretrained( "enterprise-ai-lab/sevclassifier-jev-style-1.5b", dtype=torch.float32).eval() SYS = ( "You are an incident severity classification assistant. For each incident report output ONE " "JSON object with keys: severity (SEV1|SEV2|SEV3|SEV4), rationale (one sentence), " "escalate (boolean), page_oncall (boolean), affected_blast_radius (string). " "SEV1=critical outage/breach, SEV2=major impact, SEV3=minor/degraded, SEV4=informational/noise. " "Output only the JSON.") def classify_incident(title, details): content = f"Incident: {title}\n\nDetails: {details}" msgs = [{"role": "system", "content": SYS}, {"role": "user", "content": content}] prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True) ids = tok(prompt, return_tensors="pt") with torch.no_grad(): out = model.generate(**ids, max_new_tokens=150, do_sample=False, pad_token_id=tok.eos_token_id) text = tok.decode(out[0][ids["input_ids"].shape[1]:], skip_special_tokens=True) m = re.search(r"\{.*\}", text, re.DOTALL) return json.loads(m.group(0)) if m else {} result = classify_incident( "Production database unreachable", "Primary RDS instance not responding. All pods returning 500. 12k users affected.")# {"severity": "SEV1", "rationale": "Full production outage.", "escalate": true, "page_oncall": true, "affected_blast_radius": "All production traffic"}