#!/usr/bin/env python3 """Two bounded 1-token synthetic requests isolate chat-template role compatibility. No voice/chat logs.""" from pathlib import Path import json, subprocess REMOTE=r''' import json,httpx rows=[] base={'model':'qwen3.8-27b','max_tokens':1,'temperature':0,'stream':False,'chat_template_kwargs':{'enable_thinking':False}} with httpx.Client(timeout=15,trust_env=False) as client: for mode,messages in [ ('two_system',[{'role':'system','content':'简短回答。'},{'role':'system','content':'本轮可选摄像头观察可能误判,以用户台词为主。'},{'role':'user','content':'你好'}]), ('merged_system',[{'role':'system','content':'简短回答。本轮可选摄像头观察可能误判,以用户台词为主。'},{'role':'user','content':'你好'}])]: response=client.post('http://127.0.0.1:8888/v1/chat/completions',json={**base,'messages':messages}) text=response.text.lower() row={'mode':mode,'http_status':response.status_code,'body_chars':len(text), 'role_or_template_error':any(x in text for x in ('system role','system message','roles must','chat template','conversation roles','only supports','alternat'))} # Fixed synthetic inputs only; errors are classified, never save response text. try: data=response.json() row['error_type']=str(data.get('error',{}).get('type',''))[:80] row['completion_tokens']=data.get('usage',{}).get('completion_tokens') except Exception: pass rows.append(row) print(json.dumps({'results':rows})) ''' root=Path(__file__).resolve().parents[1] command=('cd /home/gorios-spark-2/lan-voice && if [ -x .venv/bin/python ]; then exec .venv/bin/python -; elif [ -x venv/bin/python ]; then exec venv/bin/python -; else exec python3 -; fi') r=subprocess.run(['ssh','-o','BatchMode=yes','-o','ConnectTimeout=5','gorios-spark-2@192.168.31.61',command],input=REMOTE.encode(),capture_output=True,timeout=45) if r.stdout: data=json.loads(r.stdout) (root/'logs/voice-investigation/backend-template.json').write_text(json.dumps(data,indent=2)+'\n') print(json.dumps(data)) if r.stderr: print('Remote stderr present; no content printed.') raise SystemExit(r.returncode)