File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
expression_measurement/stream Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 1010import websockets .protocol
1111from json .decoder import JSONDecodeError
1212
13+ try :
14+ from websockets .legacy .client import connect as websockets_client_connect # type: ignore
15+ except ImportError :
16+ from websockets import connect as websockets_client_connect # type: ignore
17+
1318from hume .core .websocket import (
1419 OnErrorHandlerType ,
1520 OnMessageHandlerType ,
@@ -356,7 +361,7 @@ async def connect(
356361 ws_uri = await self ._construct_ws_uri (options )
357362
358363 try :
359- async with websockets . connect (
364+ async with websockets_client_connect (
360365 ws_uri ,
361366 extra_headers = exclude_auth_headers (self .client_wrapper .get_headers ()),
362367 max_size = self .DEFAULT_MAX_PAYLOAD_SIZE_BYTES ,
@@ -448,7 +453,7 @@ async def connect_with_callbacks(
448453 background_task : typing .Optional [asyncio .Task [None ]] = None
449454
450455 try :
451- async with websockets . connect (
456+ async with websockets_client_connect (
452457 ws_uri ,
453458 extra_headers = exclude_auth_headers (self .client_wrapper .get_headers ()),
454459 max_size = self .DEFAULT_MAX_PAYLOAD_SIZE_BYTES ,
Original file line number Diff line number Diff line change 99import websockets
1010import websockets .protocol
1111
12+ try :
13+ from websockets .legacy .client import connect as websockets_client_connect # type: ignore
14+ except ImportError :
15+ from websockets import connect as websockets_client_connect # type: ignore
16+
1217from hume .core .api_error import ApiError
1318
1419from .stream .types .config import Config
@@ -216,7 +221,7 @@ async def connect(
216221
217222 base = self .client_wrapper .get_environment ().base .replace ('https://' , 'wss://' ).replace ('http://' , 'ws://' )
218223 try :
219- async with websockets . connect ( # type: ignore[attr-defined]
224+ async with websockets_client_connect (
220225 f"{ base } /v0/stream/models" ,
221226 extra_headers = {
222227 ** exclude_auth_headers (self .client_wrapper .get_headers ()),
You can’t perform that action at this time.
0 commit comments