MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / _handle_human_input

Method _handle_human_input

server/services/message_handler.py:38–71  ·  view source on GitHub ↗
(self, session_id: str, data: Dict[str, Any], websocket_manager)

Source from the content-addressed store, hash-verified

36 )
37
38 async def _handle_human_input(self, session_id: str, data: Dict[str, Any], websocket_manager):
39 try:
40 payload = data.get("data", {}) or {}
41 user_input = payload.get("input", "")
42 attachments = payload.get("attachments") or []
43
44 if not user_input and not attachments:
45 await websocket_manager.send_message(
46 session_id,
47 {"type": "error", "data": {"message": "Empty input"}},
48 )
49 return
50
51 self.session_controller.provide_human_input(
52 session_id,
53 {"text": user_input, "attachments": attachments},
54 )
55
56 await websocket_manager.send_message(
57 session_id,
58 {"type": "input_received", "data": {"message": "Input received"}},
59 )
60
61 except ValidationError as exc:
62 await websocket_manager.send_message(
63 session_id,
64 {"type": "error", "data": {"message": str(exc)}},
65 )
66 except Exception as exc:
67 self.logger.error("Error handling human input for session %s: %s", session_id, exc)
68 await websocket_manager.send_message(
69 session_id,
70 {"type": "error", "data": {"message": str(exc)}},
71 )
72
73 async def _handle_ping(self, session_id: str, websocket_manager):
74 await websocket_manager.handle_heartbeat(session_id)

Callers 1

handle_messageMethod · 0.95

Calls 4

send_messageMethod · 0.80
provide_human_inputMethod · 0.80
getMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected