MCPcopy Create free account
hub / github.com/InfinitiBit/graphbit / send_websocket_message

Function send_websocket_message

examples/chatbot/frontend/chatbot.py:92–105  ·  view source on GitHub ↗

Connect, send a message, yield responses, and disconnect.

(message)

Source from the content-addressed store, hash-verified

90
91
92def send_websocket_message(message):
93 """Connect, send a message, yield responses, and disconnect."""
94 ws = connect_websocket()
95 if ws:
96 try:
97 ws.send(json.dumps({"message": message, "session_id": str(uuid.uuid4())}))
98 while True:
99 try:
100 response = ws.recv()
101 yield response
102 except websocket.WebSocketConnectionClosedException:
103 break
104 finally:
105 disconnect_websocket()
106
107
108# Accept user input

Callers 1

chatbot.pyFile · 0.85

Calls 2

connect_websocketFunction · 0.85
disconnect_websocketFunction · 0.85

Tested by

no test coverage detected