ojin-client 0.1.7.dev0__tar.gz → 0.1.7.dev2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ojin-client
3
- Version: 0.1.7.dev0
3
+ Version: 0.1.7.dev2
4
4
  Summary: Ojin platform services
5
5
  Author: Journee
6
6
  License: Apache-2.0
@@ -86,6 +86,7 @@ class OjinPersonaClient(IOjinPersonaClient):
86
86
  self._running = False
87
87
  self._receive_task: Optional[asyncio.Task] = None
88
88
  self._inference_server_ready: bool = False
89
+ self._cancelled = True
89
90
 
90
91
  async def connect(self) -> None:
91
92
  """Establish WebSocket connection and authenticate with the service."""
@@ -261,11 +262,19 @@ class OjinPersonaClient(IOjinPersonaClient):
261
262
  payload=message.to_proxy_message()
262
263
  )
263
264
 
264
- if self._message_queue.empty():
265
- self._message_queue = asyncio.Queue()
266
-
267
265
  await self._ws.send(cancel_input.model_dump_json())
268
266
 
267
+ logger.info(f"Message sent {message.interaction_id}")
268
+
269
+ while not self._message_queue.empty():
270
+ try:
271
+ self._message_queue.get_nowait()
272
+ except asyncio.QueueEmpty:
273
+ break
274
+
275
+
276
+ self._cancelled = False
277
+
269
278
  return
270
279
 
271
280
  if isinstance(message, StartInteractionMessage):
@@ -281,6 +290,7 @@ class OjinPersonaClient(IOjinPersonaClient):
281
290
 
282
291
  if isinstance(message, OjinPersonaInteractionInputMessage):
283
292
  logger.info("InteractionMessage")
293
+ logger.info(f"Message sent {message.interaction_id}")
284
294
  if not message.audio_int16_bytes:
285
295
  raise ValueError("Audio cannot be empty")
286
296
 
@@ -321,7 +331,7 @@ class OjinPersonaClient(IOjinPersonaClient):
321
331
  )
322
332
  raise Exception(error)
323
333
 
324
- async def receive_message(self) -> BaseModel:
334
+ async def receive_message(self) -> BaseModel | None:
325
335
  """Receive the next message from the OJIN Persona service.
326
336
 
327
337
  Returns:
@@ -331,6 +341,8 @@ class OjinPersonaClient(IOjinPersonaClient):
331
341
  asyncio.QueueEmpty: If no messages are available
332
342
 
333
343
  """
344
+ if self._cancelled:
345
+ return None
334
346
  return await self._message_queue.get()
335
347
 
336
348
  def is_connected(self) -> bool:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ojin-client
3
- Version: 0.1.7.dev0
3
+ Version: 0.1.7.dev2
4
4
  Summary: Ojin platform services
5
5
  Author: Journee
6
6
  License: Apache-2.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ojin-client"
3
- version = "0.1.7dev"
3
+ version = "0.1.7dev2"
4
4
  description = "Ojin platform services"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"