new _backend

This commit is contained in:
2025-01-07 14:21:46 +08:00
parent 87c87aa328
commit 1fd031d6e6
59 changed files with 10633 additions and 0 deletions

20
_backend/testchat.py Normal file
View 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