Files
weval-l99/pw-multiagent.py
2026-04-19 18:05:32 +02:00

88 lines
3.5 KiB
Python

import time, json, subprocess
from pathlib import Path
from playwright.sync_api import sync_playwright
TS = time.strftime("%Y%m%d-%H%M%S")
OUT = Path(f"/var/www/html/test-report/multiagent-truth-{TS}")
OUT.mkdir(parents=True, exist_ok=True)
results = {"ts": TS, "steps": []}
try:
with sync_playwright() as p:
browser = p.chromium.launch(headless=True, args=["--no-sandbox"])
ctx = browser.new_context(
viewport={"width":1400,"height":1200},
ignore_https_errors=True,
record_video_dir=str(OUT),
record_video_size={"width":1400,"height":1200}
)
page = ctx.new_page()
# 1. Open WEVIA Master chat
page.goto("https://weval-consulting.com/wevia-master.html", wait_until="networkidle", timeout=25000)
time.sleep(4)
page.screenshot(path=str(OUT/"01-master-chat.png"), full_page=True)
results["steps"].append({"step": "open_chat", "ok": True})
# 2. Find chat input
inputs = page.locator('textarea, input[type="text"]').all()
print(f"Found {len(inputs)} possible inputs")
# Try different selectors for chat input
for sel in ['textarea[placeholder*="ssage"]', 'input[placeholder*="ssage"]', 'textarea', '#chat-input', '.chat-input']:
try:
el = page.locator(sel).first
if el.count() > 0:
print(f"Using selector: {sel}")
el.fill("wevia truth")
time.sleep(1)
page.keyboard.press("Enter")
time.sleep(6)
page.screenshot(path=str(OUT/"02-truth-response.png"), full_page=True)
results["steps"].append({"step": "sent_truth", "ok": True, "selector": sel})
break
except Exception as e:
continue
# 3. Test multiagent trigger
time.sleep(2)
try:
for sel in ['textarea', 'input[type="text"]']:
el = page.locator(sel).first
if el.count() > 0:
el.fill("agis en multiagent 10 agents parallèles")
page.keyboard.press("Enter")
time.sleep(15) # SSE multiagent takes time
page.screenshot(path=str(OUT/"03-multiagent.png"), full_page=True)
results["steps"].append({"step": "multiagent", "ok": True})
break
except Exception as e:
results["steps"].append({"step": "multiagent", "ok": False, "err": str(e)})
# 4. Direct API calls proof
resp_truth = page.request.post(
"https://weval-consulting.com/api/wevia-master-api.php?fast=1",
data={"message": "wevia truth"},
headers={"Content-Type": "application/json"},
)
truth_data = resp_truth.json()
results["truth_api_agents"] = truth_data.get("output", "")[:500]
ctx.close()
browser.close()
# Find video
videos = list(OUT.glob("*.webm"))
results["video"] = str(videos[0].name) if videos else None
results["screenshots"] = [p.name for p in OUT.glob("*.png")]
with open(OUT / "results.json", "w") as f:
json.dump(results, f, indent=2, default=str)
print(json.dumps({
"steps": len(results["steps"]),
"screenshots": len(results["screenshots"]),
"video": results["video"]
}, indent=2))
except Exception as e:
print(f"err: {e}")