Spaces:
Runtime error
Runtime error
| import asyncio | |
| import websockets | |
| import time | |
| wsaddress = "wss://gpt2-chat.ai-research.id/"; | |
| #wsaddress = "ws://localhost:8502"; | |
| async def hello(): | |
| async with websockets.connect(wsaddress) as websocket: | |
| for i in range(0, 100, 10): | |
| await websocket.send(f"Hello world! Nmber: {i}") | |
| msg = await websocket.recv() | |
| print(f"Msg: {msg}") | |
| time.sleep(2) | |
| await websocket.send(f"Bye") | |
| msg = await websocket.recv() | |
| print(f"Msg: {msg}") | |
| asyncio.run(hello()) | |