File size: 531 Bytes
e3f06ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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())