1717from typing import (
1818 TYPE_CHECKING ,
1919 Any ,
20- Dict ,
2120 Iterator ,
22- List ,
2321 Mapping ,
2422 Optional ,
2523 Sequence ,
5755 try :
5856 from websockets .typing import Subprotocol as WSSubprotocol # runtime if available
5957 except Exception :
58+
6059 class WSSubprotocol (str ): # fallback, keeps runtime simple
6160 pass
6261
62+
6363if TYPE_CHECKING :
6464 # Not imported at runtime; only for type checkers (mypy/pyright).
6565 from websockets .sync .client import ClientConnection as _WSClientConnection
@@ -69,7 +69,7 @@ class WSSubprotocol(str): # fallback, keeps runtime simple
6969else :
7070 from typing_extensions import NotRequired # noqa: F401
7171
72- __all__ : List [str ] = [
72+ __all__ : list [str ] = [
7373 "connect" ,
7474 "WebsocketConnectionOptions" ,
7575 "ConnectionError" ,
@@ -339,7 +339,7 @@ def clear(self, *, event_id: Optional[str] = None) -> None:
339339 :return: None
340340 :rtype: None
341341 """
342- event : Dict [str , Any ] = {"type" : "output_audio_buffer.clear" }
342+ event : dict [str , Any ] = {"type" : "output_audio_buffer.clear" }
343343 if event_id :
344344 event ["event_id" ] = event_id
345345 self ._connection .send (event )
@@ -357,11 +357,7 @@ def __init__(self, connection: "VoiceLiveConnection") -> None:
357357 self ._connection = connection
358358
359359 def create (
360- self ,
361- * ,
362- item : Mapping [str , Any ],
363- previous_item_id : Optional [str ] = None ,
364- event_id : Optional [str ] = None
360+ self , * , item : Mapping [str , Any ], previous_item_id : Optional [str ] = None , event_id : Optional [str ] = None
365361 ) -> None :
366362 """Create a new conversation item.
367363
@@ -477,7 +473,7 @@ def update(self, *, session: Mapping[str, Any], event_id: Optional[str] = None)
477473 :return: None
478474 :rtype: None
479475 """
480- event : Dict [str , Any ] = {"type" : "transcription_session.update" , "session" : dict (session )}
476+ event : dict [str , Any ] = {"type" : "transcription_session.update" , "session" : dict (session )}
481477 if event_id :
482478 event ["event_id" ] = event_id
483479 self ._connection .send (event )
@@ -674,14 +670,14 @@ def __enter__(self) -> VoiceLiveConnection:
674670
675671 # Build headers as str->str and use list of tuples to satisfy HeadersLike
676672 extra_headers_map : Mapping [str , Any ] = self .__extra_headers or {}
677- merged_headers : Dict [str , str ] = {
673+ merged_headers : dict [str , str ] = {
678674 ** self ._get_auth_headers (),
679675 ** {str (k ): str (v ) for k , v in extra_headers_map .items ()},
680676 }
681- headers_like : List [Tuple [str , str ]] = list (merged_headers .items ())
677+ headers_like : list [Tuple [str , str ]] = list (merged_headers .items ())
682678
683679 # Build kwargs for websockets; avoid dict(Optional[...])
684- ws_kwargs : Dict [str , Any ] = {}
680+ ws_kwargs : dict [str , Any ] = {}
685681 if self .__connection_options is not None :
686682 ws_kwargs .update (cast (Mapping [str , Any ], self .__connection_options ))
687683
@@ -715,7 +711,7 @@ def __exit__(self, exc_type, exc, exc_tb) -> None:
715711 if self .__connection is not None :
716712 self .__connection .close ()
717713
718- def _get_auth_headers (self ) -> Dict [str , str ]:
714+ def _get_auth_headers (self ) -> dict [str , str ]:
719715 """Get authentication headers for WebSocket connection.
720716
721717 :return: A dictionary containing authentication headers.
@@ -735,7 +731,7 @@ def _prepare_url(self) -> str:
735731 parsed = urlparse (self ._endpoint )
736732 scheme = "wss" if parsed .scheme == "https" else ("ws" if parsed .scheme == "http" else parsed .scheme )
737733
738- params : Dict [str , str ] = {"model" : self .__model , "api-version" : self .__api_version }
734+ params : dict [str , str ] = {"model" : self .__model , "api-version" : self .__api_version }
739735 extra_query : Mapping [str , Any ] = self .__extra_query or {}
740736 for k , v in extra_query .items ():
741737 params [str (k )] = str (v )
@@ -746,7 +742,7 @@ def _prepare_url(self) -> str:
746742 if key not in params :
747743 params [key ] = value_list [0 ] if value_list else ""
748744
749- path = parsed .path .rstrip ("/" ) + "/voice-agent /realtime"
745+ path = parsed .path .rstrip ("/" ) + "/voice-live /realtime"
750746 return urlunparse ((scheme , parsed .netloc , path , parsed .params , urlencode (params ), parsed .fragment ))
751747
752748
0 commit comments