#!/bin/bash
# 等渲染窗口 → 正向路径冒烟: vision_verify 默认引擎序 (qwen-eye 优先) 真图判定
cd /data/workspace/kais-hermes-skills
for i in $(seq 1 360); do  # 最多 3 小时
  FREE=$(nvidia-smi --query-gpu=memory.free --format=csv,noheader,nounits -i 1)
  RUN=$(curl -s -m 2 http://127.0.0.1:8188/queue | python3 -c "import json,sys;print(len(json.load(sys.stdin)['queue_running']))" 2>/dev/null || echo 99)
  if [ "$FREE" -ge 14000 ] && [ "$RUN" = "0" ]; then
    echo "[$(date +%H:%M:%S)] window: free=${FREE}MB queue=0 → smoke"
    python3 -c "
import asyncio, logging, sys, time
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
from plugins.kais_aigc.vision_verify import verify_image_content
img = '/home/kai/shared/qwen-eye-exp/frames_catvideo/frame_28s.jpg'
t0 = time.time()
r = asyncio.run(verify_image_content(img, 'two cats (one white, one orange) pushing a cardboard box together'))
print(f'SMOKE_OK elapsed={time.time()-t0:.0f}s')
print('RESULT:', {k: v for k, v in r.items() if k != 'description'})
print('DESC:', (r.get('description') or '')[:200])
" 2>&1 | grep -Ev "^INFO:(urllib3|httpx|openai)" | tail -8
    /opt/qwen-llm/kap-llm.sh stop
    echo "SMOKE_DONE_STOPPED"
    exit 0
  fi
  sleep 30
done
echo "TIMEOUT_3h"
