Spaces:
Runtime error
Runtime error
File size: 469 Bytes
c32808f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import asyncio
import websockets
async def chat_with_websocket(url, message):
async with websockets.connect(url) as websocket:
await websocket.send(message)
response = await websocket.recv()
print(response)
server = "localhost"
port = 22222
ws_url = f"ws://{server}:{port}/create"
prompt = "Hello, who are you?"
event_loop = asyncio.get_event_loop()
event_loop.run_until_complete(chat_with_websocket(ws_url, prompt))
event_loop.close()
|