feat: unify card runtime and event-driven web ui
This commit is contained in:
parent
0edf8c3fef
commit
4dfb7ca3cc
105 changed files with 17382 additions and 8505 deletions
|
|
@ -1127,6 +1127,7 @@ class WebRTCVoiceSession:
|
|||
self._last_stt_backlog_notice_at = 0.0
|
||||
self._ptt_pressed = False
|
||||
self._active_message_metadata: dict[str, Any] = {}
|
||||
self._active_chat_id = "web"
|
||||
|
||||
def set_push_to_talk_pressed(self, pressed: bool) -> None:
|
||||
self._ptt_pressed = bool(pressed)
|
||||
|
|
@ -1214,6 +1215,7 @@ class WebRTCVoiceSession:
|
|||
await self._close_peer_connection()
|
||||
self._ptt_pressed = False
|
||||
self._active_message_metadata = {}
|
||||
self._active_chat_id = "web"
|
||||
|
||||
peer_connection = RTCPeerConnection()
|
||||
self._pc = peer_connection
|
||||
|
|
@ -1239,13 +1241,15 @@ class WebRTCVoiceSession:
|
|||
return
|
||||
msg_type = str(msg.get("type", "")).strip()
|
||||
if msg_type == "voice-ptt":
|
||||
self._active_chat_id = str(msg.get("chat_id", "web")).strip() or "web"
|
||||
self._active_message_metadata = _coerce_message_metadata(msg.get("metadata", {}))
|
||||
self.set_push_to_talk_pressed(bool(msg.get("pressed", False)))
|
||||
elif msg_type == "command":
|
||||
command = str(msg.get("command", "")).strip()
|
||||
chat_id = str(msg.get("chat_id", self._active_chat_id)).strip() or "web"
|
||||
if command == "reset":
|
||||
self.interrupt_output()
|
||||
asyncio.create_task(self._gateway.send_command(command))
|
||||
asyncio.create_task(self._gateway.send_command(command, chat_id=chat_id))
|
||||
elif msg_type == "card-response":
|
||||
asyncio.create_task(
|
||||
self._gateway.send_card_response(
|
||||
|
|
@ -1602,6 +1606,7 @@ class WebRTCVoiceSession:
|
|||
await self._gateway.send_user_message(
|
||||
transcript,
|
||||
metadata=dict(segment.metadata),
|
||||
chat_id=self._active_chat_id,
|
||||
)
|
||||
except RuntimeError as exc:
|
||||
if self._closed:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue