- Serveur WebSocket direct avec websockets 16.0 - Interface HTML/CSS/JS dark theme avec chat - Relay vers API Hermes sur port 8642 - Historique de conversation (20 messages) - Clé API via Infisical - Testé et fonctionnel sur openclaw1.dev.home:7081
51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
|
|
import asyncio
|
|
import websockets
|
|
import json
|
|
import time
|
|
|
|
async def test():
|
|
t0 = time.time()
|
|
print("🔌 Connexion WebSocket à ws://localhost:7081/ws...")
|
|
try:
|
|
async with websockets.connect('ws://localhost:7081/ws', open_timeout=10) as ws:
|
|
t_connect = time.time() - t0
|
|
print(f"✅ Connecté en {t_connect:.1f}s!")
|
|
|
|
# Receive welcome message
|
|
try:
|
|
msg = await asyncio.wait_for(ws.recv(), timeout=15)
|
|
print(f"📩 Bienvenue: {msg[:200]}")
|
|
except asyncio.TimeoutError:
|
|
print("⚠️ Pas de message de bienvenue")
|
|
|
|
# Send a question
|
|
t1 = time.time()
|
|
print("📤 Envoi: 'Quelle heure est-il ?'")
|
|
await ws.send("Quelle heure est-il ?")
|
|
|
|
# Get response
|
|
try:
|
|
response = await asyncio.wait_for(ws.recv(), timeout=90)
|
|
t_resp = time.time() - t1
|
|
print(f"📩 Réponse ({t_resp:.1f}s): {response[:500]}")
|
|
except asyncio.TimeoutError:
|
|
print("❌ Timeout: pas de réponse du LLM en 90s")
|
|
|
|
# Send second question
|
|
t2 = time.time()
|
|
print("📤 Envoi: 'Quel temps fait-il aujourd''hui ?'")
|
|
await ws.send("Quel temps fait-il aujourd'hui ?")
|
|
|
|
try:
|
|
response2 = await asyncio.wait_for(ws.recv(), timeout=90)
|
|
t_resp2 = time.time() - t2
|
|
print(f"📩 Réponse 2 ({t_resp2:.1f}s): {response2[:500]}")
|
|
except asyncio.TimeoutError:
|
|
print("❌ Timeout: pas de réponse 2 en 90s")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Erreur: {type(e).__name__}: {e}")
|
|
|
|
asyncio.run(test())
|