77import websockets
88import websockets .sync .connection as websockets_sync_connection
99from ...core .events import EventEmitterMixin , EventType
10- from ...core .pydantic_utilities import parse_obj_as
10+ from ...core .unchecked_base_model import construct_type
1111from .types .agent_v1agent_audio_done import AgentV1AgentAudioDone
1212from .types .agent_v1agent_started_speaking import AgentV1AgentStartedSpeaking
1313from .types .agent_v1agent_thinking import AgentV1AgentThinking
@@ -64,7 +64,7 @@ async def __aiter__(self):
6464 if isinstance (message , bytes ):
6565 yield message
6666 else :
67- yield parse_obj_as ( V1SocketClientResponse , json .loads (message )) # type: ignore
67+ yield construct_type ( type_ = V1SocketClientResponse , object_ = json .loads (message )) # type: ignore
6868
6969 async def start_listening (self ):
7070 """
@@ -83,7 +83,7 @@ async def start_listening(self):
8383 parsed = raw_message
8484 else :
8585 json_data = json .loads (raw_message )
86- parsed = parse_obj_as ( V1SocketClientResponse , json_data ) # type: ignore
86+ parsed = construct_type ( type_ = V1SocketClientResponse , object_ = json_data ) # type: ignore
8787 await self ._emit_async (EventType .MESSAGE , parsed )
8888 except Exception as exc :
8989 await self ._emit_async (EventType .ERROR , exc )
@@ -154,7 +154,7 @@ async def recv(self) -> V1SocketClientResponse:
154154 if isinstance (data , bytes ):
155155 return data # type: ignore
156156 json_data = json .loads (data )
157- return parse_obj_as ( V1SocketClientResponse , json_data ) # type: ignore
157+ return construct_type ( type_ = V1SocketClientResponse , object_ = json_data ) # type: ignore
158158
159159 async def _send (self , data : typing .Any ) -> None :
160160 """
@@ -181,7 +181,7 @@ def __iter__(self):
181181 if isinstance (message , bytes ):
182182 yield message
183183 else :
184- yield parse_obj_as ( V1SocketClientResponse , json .loads (message )) # type: ignore
184+ yield construct_type ( type_ = V1SocketClientResponse , object_ = json .loads (message )) # type: ignore
185185
186186 def start_listening (self ):
187187 """
@@ -200,7 +200,7 @@ def start_listening(self):
200200 parsed = raw_message
201201 else :
202202 json_data = json .loads (raw_message )
203- parsed = parse_obj_as ( V1SocketClientResponse , json_data ) # type: ignore
203+ parsed = construct_type ( type_ = V1SocketClientResponse , object_ = json_data ) # type: ignore
204204 self ._emit (EventType .MESSAGE , parsed )
205205 except Exception as exc :
206206 self ._emit (EventType .ERROR , exc )
@@ -271,7 +271,7 @@ def recv(self) -> V1SocketClientResponse:
271271 if isinstance (data , bytes ):
272272 return data # type: ignore
273273 json_data = json .loads (data )
274- return parse_obj_as ( V1SocketClientResponse , json_data ) # type: ignore
274+ return construct_type ( type_ = V1SocketClientResponse , object_ = json_data ) # type: ignore
275275
276276 def _send (self , data : typing .Any ) -> None :
277277 """
0 commit comments