ojin-client 0.1.7.dev0__tar.gz → 0.1.7.dev1__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.dev1
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: bool = False
89
90
 
90
91
  async def connect(self) -> None:
91
92
  """Establish WebSocket connection and authenticate with the service."""
@@ -260,12 +261,16 @@ class OjinPersonaClient(IOjinPersonaClient):
260
261
  cancel_input = CancelInteractionMessage(
261
262
  payload=message.to_proxy_message()
262
263
  )
263
-
264
- if self._message_queue.empty():
265
- self._message_queue = asyncio.Queue()
264
+ self._cancelled = True
265
+ while not self._message_queue.empty():
266
+ try:
267
+ self._message_queue.get_nowait()
268
+ except asyncio.QueueEmpty:
269
+ break
266
270
 
267
271
  await self._ws.send(cancel_input.model_dump_json())
268
272
 
273
+ self._cancelled = False
269
274
  return
270
275
 
271
276
  if isinstance(message, StartInteractionMessage):
@@ -314,6 +319,8 @@ class OjinPersonaClient(IOjinPersonaClient):
314
319
  await self.close()
315
320
  error = ErrorResponseMessage(
316
321
  payload=ErrorResponse(
322
+ interaction_id="",
323
+ details={},
317
324
  code="UNKNOWN",
318
325
  message="The message is Unknown",
319
326
  timestamp=int(time.monotonic() * 1000),
@@ -321,7 +328,7 @@ class OjinPersonaClient(IOjinPersonaClient):
321
328
  )
322
329
  raise Exception(error)
323
330
 
324
- async def receive_message(self) -> BaseModel:
331
+ async def receive_message(self) -> BaseModel | None:
325
332
  """Receive the next message from the OJIN Persona service.
326
333
 
327
334
  Returns:
@@ -331,6 +338,8 @@ class OjinPersonaClient(IOjinPersonaClient):
331
338
  asyncio.QueueEmpty: If no messages are available
332
339
 
333
340
  """
341
+ if self._cancelled:
342
+ return None
334
343
  return await self._message_queue.get()
335
344
 
336
345
  def is_connected(self) -> bool:
@@ -210,7 +210,7 @@ class IOjinPersonaClient(ABC):
210
210
  """
211
211
 
212
212
  @abstractmethod
213
- async def receive_message(self) -> BaseModel:
213
+ async def receive_message(self) -> BaseModel | None:
214
214
  """Receive a message from the server.
215
215
 
216
216
  Returns:
@@ -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.dev1
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.7dev1"
4
4
  description = "Ojin platform services"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"