Files
html/api/vision-debug.sh
opus 5f015fb49a
Some checks failed
WEVAL NonReg / nonreg (push) Has been cancelled
auto-sync-0305
2026-04-17 03:05:02 +02:00

47 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# WEVIA Vision Debug — screenshot + AI analysis
PAGE=$1
if [ -z "$PAGE" ]; then echo "Usage: vision-debug.sh <page-name>"; exit 1; fi
echo "=== SCREENSHOT ==="
python3 -c "
from playwright.sync_api import sync_playwright
import base64, json, time, subprocess
p=sync_playwright().start()
b=p.chromium.launch(headless=True)
pg=b.new_page()
errs=[]
pg.on('pageerror',lambda e:errs.append(str(e)[:80]))
pg.goto('https://weval-consulting.com/${PAGE}.html',wait_until='domcontentloaded',timeout=10000)
time.sleep(2)
# Screenshot
pg.screenshot(path='/tmp/vision-debug.png')
print(f'JS_ERRORS: {len(errs)}')
for e in errs: print(f' ERROR: {e}')
# Encode screenshot for vision model
with open('/tmp/vision-debug.png','rb') as f:
img_b64 = base64.b64encode(f.read()).decode()
# Send to Moondream (local vision model)
import requests as rq
r = rq.post('http://127.0.0.1:11434/api/generate', json={
'model':'moondream',
'prompt':'Describe this web page. Is there any visual bug, error message, broken layout, overlapping elements, or missing content? Be specific about what you see.',
'images':[img_b64],
'stream':False
}, timeout=60)
d = r.json()
print(f'VISION: {d.get("response","no response")[:300]}')
# Get source code key lines
import subprocess
src = subprocess.run(['grep','-n','function\\|fetch\\|error\\|forEach\\|Object.entries','/var/www/html/${PAGE}.html'], capture_output=True, text=True)
print(f'SOURCE_LINES: {src.stdout[:300]}')
b.close()
p.stop()
" 2>&1