
    qi                         d Z ddlZddlmZ ddlmZ ddlmZmZ 	 ddl	m
Z e G d de             Z G d de      Zy# e$ r7Z ej                  de         ej                  d	        ed
e       dZ[ww xY w)z6Azure OpenAI Realtime Beta LLM service implementation.    N)	dataclass)logger   )OpenAIRealtimeBetaLLMServiceOpenAIRealtimeBetaLLMSettings)connectzException: zvIn order to use OpenAI, you need to `pip install pipecat-ai[openai]`. Also, set `OPENAI_API_KEY` environment variable.zMissing module: c                       e Zd ZdZy)AzureRealtimeBetaLLMSettingsz)Settings for AzureRealtimeBetaLLMService.N)__name__
__module____qualname____doc__     ]/opt/pipecat/venv/lib/python3.12/site-packages/pipecat/services/openai_realtime_beta/azure.pyr
   r
      s    3r   r
   c                   B     e Zd ZU dZeZeed<   dedef fdZd Z	 xZ
S )AzureRealtimeBetaLLMServicea  Azure OpenAI Realtime Beta LLM service with Azure-specific authentication.

    .. deprecated:: 0.0.84
        `AzureRealtimeBetaLLMService` is deprecated, use `AzureRealtimeLLMService` instead.
        This class will be removed in version 1.0.0.

    Extends the OpenAI Realtime service to work with Azure OpenAI endpoints,
    using Azure's authentication headers and endpoint format. Provides the same
    real-time audio and text communication capabilities as the base OpenAI service.
    	_settingsapi_keybase_urlc                    t        |   d||d| t        j                         5  t        j                  d       t        j
                  dt        d       ddd       || _        || _        y# 1 sw Y   xY w)a  Initialize Azure Realtime Beta LLM service.

        Args:
            api_key: The API key for the Azure OpenAI service.
            base_url: The full Azure WebSocket endpoint URL including api-version and deployment.
                Example: "wss://my-project.openai.azure.com/openai/realtime?api-version=2024-10-01-preview&deployment=my-realtime-deployment"
            **kwargs: Additional arguments passed to parent OpenAIRealtimeBetaLLMService.
        )r   r   alwaysztAzureRealtimeBetaLLMService is deprecated and will be removed in version 1.0.0. Use AzureRealtimeLLMService instead.   )
stacklevelNr   )	super__init__warningscatch_warningssimplefilterwarnDeprecationWarningr   r   )selfr   r   kwargs	__class__s       r   r   z$AzureRealtimeBetaLLMService.__init__0   sr     	F(GFvF$$& 	!!(+MM7"		  	 	s   2A11A:c                   K   	 | j                   ry t        j                  d| j                          t	        | j                  d| j
                  i       d {   | _         | j                  | j                               | _        y 7 .# t        $ r0}| j                  d| |       d {  7   d | _         Y d }~y d }~ww xY ww)NzConnecting to zapi-key)uriadditional_headerszError connecting: )	error_msg	exception)
_websocketr   infor   websocket_connectr   create_task_receive_task_handler_receive_task	Exception
push_error)r"   es     r   _connectz$AzureRealtimeBetaLLMService._connectM   s     	# KK.89$5MMt||$% DO "&!1!1$2L2L2N!OD  	#//.@,DPQ/RRR"DOO	#sW   CB
 CAB
 B-B
 CB
 
	CB>,B/-B>9C>CC)r   r   r   r   r
   Settings__annotations__strr   r3   __classcell__)r$   s   @r   r   r   !   s3    	 ,H++! ! 	!:#r   r   )r   r   dataclassesr   logurur   openair   r   websockets.asyncio.clientr   r,   ModuleNotFoundErrorr2   errorr0   r
   r   r   r   r   <module>r>      s    =  !  O,F 	#@ 	 	=#"> =#  ,FLL;qc"#FLL 	A &qc*
++,s   > A:2A55A: