Files
matagent/backend/testchat.py
2025-01-18 17:53:58 +08:00

20 lines
670 B
Python
Executable File

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