new _backend
This commit is contained in:
20
_backend/testchat.py
Normal file
20
_backend/testchat.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from websockets.sync.client import connect as ws_connect
|
||||
|
||||
uri = "ws://0.0.0.0:8765"
|
||||
with ws_connect(uri) as websocket:
|
||||
print(f" - Connected to server on {uri}", flush=True)
|
||||
|
||||
print(" - Sending message to server.", flush=True)
|
||||
# websocket.send("2+2=?")
|
||||
websocket.send("Check out the weather in Paris and write a poem about it.")
|
||||
|
||||
while True:
|
||||
message = websocket.recv()
|
||||
message = message.decode("utf-8") if isinstance(message, bytes) else message
|
||||
|
||||
print(message, end="", flush=True)
|
||||
|
||||
if "TERMINATE" in message:
|
||||
print()
|
||||
print(" - Received TERMINATE message. Exiting.", flush=True)
|
||||
break
|
||||
Reference in New Issue
Block a user