import json, urllib.request, collections KEY=open('/home/lkraven/.config/litellm/infra-ops-key').read().strip() URL="http://10.250.50.70:4000/v1/chat/completions" PROMPTS=[ ("reasoning","A farmer has 17 sheep. All but 9 run away. He buys twice as many as he has left, then sells 4. How many now? Explain."), ("summarize","Summarise these in one sentence each:\n1. Fed holds rates, signals two cuts\n2. Port strike enters third week\n3. Study links microplastics to soil carbon loss"), ("classify","Classify the sentiment of each line as POSITIVE, NEGATIVE or NEUTRAL:\n1. The deploy finally went clean.\n2. Third outage this week.\n3. Meeting moved to Thursday."), ] def probe(model,n=4,maxtok=2048): t=collections.Counter(); ex=None for label,p in PROMPTS: for i in range(n): body={"model":model,"messages":[{"role":"user","content":p}],"max_tokens":maxtok} req=urllib.request.Request(URL,data=json.dumps(body).encode(), headers={"Authorization":"Bearer "+KEY,"Content-Type":"application/json"}) try: d=json.loads(urllib.request.urlopen(req,timeout=300).read().decode(),strict=False) except Exception as e: t["error"]+=1; continue c=d["choices"][0]; cont=c["message"].get("content") or "" t["n"]+=1 if "" in cont: t["LEAK"]+=1; t[f"leak_{label}"]+=1 if ex is None: ex=(label,cont[:120]) if not cont.strip(): t["empty"]+=1 if c.get("finish_reason")!="stop": t[f"finish_{c.get('finish_reason')}"]+=1 return t,ex for m in ["gen","summarizer","summarizer-large","classifier","image-judge","qwen-image-bench","gen-reasoning"]: t,ex=probe(m) leak=t.get("LEAK",0); n=t.get("n",0) pct=(100.0*leak/n) if n else 0 print(f" {m:<20} n={n:<3} LEAK={leak:<3} ({pct:4.1f}%) empty={t.get('empty',0)} " + " ".join(f"{k}={v}" for k,v in t.items() if k.startswith(('leak_','finish_')))) if ex: print(f" e.g. [{ex[0]}] {ex[1]!r}")