delay gemini multimodal live websocket connect

This commit is contained in:
Kwindla Hultman Kramer
2024-12-21 14:35:45 -08:00
parent 503eddf7d6
commit 59240c7b96
2 changed files with 6 additions and 4 deletions

View File

@@ -177,6 +177,7 @@ class GeminiMultimodalLiveLLMService(LLMService):
self._receive_task = None
self._context = None
self._connected = False
self._disconnecting = False
self._api_session_ready = False
self._run_llm_when_api_session_ready = False
@@ -230,7 +231,6 @@ class GeminiMultimodalLiveLLMService(LLMService):
async def start(self, frame: StartFrame):
await super().start(frame)
await self._connect()
async def stop(self, frame: EndFrame):
await super().stop(frame)
@@ -434,8 +434,9 @@ class GeminiMultimodalLiveLLMService(LLMService):
async def _ws_send(self, message):
# logger.debug(f"Sending message to websocket: {message}")
try:
if self._websocket:
await self._websocket.send(json.dumps(message))
if not self._websocket:
await self._connect()
await self._websocket.send(json.dumps(message))
except Exception as e:
if self._disconnecting:
return