From 07ff2e89c50fc2ff9b5a845f596e2b62ecc44304 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:48:40 -0400 Subject: [PATCH] fix: update async iterator to parse incoming message --- src/hume/empathic_voice/chat/socket_client.py | 2 +- src/hume/expression_measurement/stream/socket_client.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hume/empathic_voice/chat/socket_client.py b/src/hume/empathic_voice/chat/socket_client.py index 9aa3f4a..59b53f3 100644 --- a/src/hume/empathic_voice/chat/socket_client.py +++ b/src/hume/empathic_voice/chat/socket_client.py @@ -61,7 +61,7 @@ def __init__( async def __aiter__(self): async for message in self.websocket: - yield message + yield parse_obj_as(SubscribeEvent, json.loads(message)) async def _send(self, data: typing.Any) -> None: if isinstance(data, dict): diff --git a/src/hume/expression_measurement/stream/socket_client.py b/src/hume/expression_measurement/stream/socket_client.py index daa1202..f9c7d30 100644 --- a/src/hume/expression_measurement/stream/socket_client.py +++ b/src/hume/expression_measurement/stream/socket_client.py @@ -38,7 +38,7 @@ def __init__( async def __aiter__(self): async for message in self.websocket: - yield message + yield parse_obj_as(SubscribeEvent, json.loads(message)) # type: ignore # TODO: we can likely coerce the right response model within the union here, if we're # assuming request-response pattern and 1:1 mapping between request and response types