chat-server / app /chat_client.py
cahya's picture
first commit
e3f06ac
raw
history blame contribute delete
531 Bytes
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())