
    qi`
                         d 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)z1Azure OpenAI Realtime LLM service implementation.    )	dataclass)logger)OpenAIRealtimeLLMServiceOpenAIRealtimeLLMSettings)connectzException: zMIn order to use Azure Realtime, you need to `pip install pipecat-ai[openai]`.zMissing module: Nc                       e Zd ZdZy)AzureRealtimeLLMSettingsz%Settings for AzureRealtimeLLMService.N)__name__
__module____qualname____doc__     U/opt/pipecat/venv/lib/python3.12/site-packages/pipecat/services/azure/realtime/llm.pyr	   r	      s    /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 )AzureRealtimeLLMServicea<  Azure OpenAI Realtime LLM service with Azure-specific authentication.

    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                F    t        |   d||d| || _        || _        y)a  Initialize Azure Realtime 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=2025-04-01-preview&deployment=my-realtime-deployment"
            **kwargs: Additional arguments passed to parent OpenAIRealtimeLLMService.
        )r   r   Nr   )super__init__r   r   )selfr   r   kwargs	__class__s       r   r   z AzureRealtimeLLMService.__init__)   s*     	F(GFvF r   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initialization error: )	error_msg	exception)
_websocketr   infor   websocket_connectr   create_task_receive_task_handler_receive_task	Exception
push_error)r   es     r   _connectz AzureRealtimeLLMService._connect<   s     	# KK.89$5MMt||$% DO "&!1!1$2L2L2N!OD  	#//.DQC,HTU/VVV"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   r*   __classcell__)r   s   @r   r   r      s3     (H''! ! 	!&#r   r   )r   dataclassesr   logurur   $pipecat.services.openai.realtime.llmr   r   websockets.asyncio.clientr   r#   ModuleNotFoundErrorr)   errorr'   r	   r   r   r   r   <module>r5      s    8 !  d,F 	8 	 	/#6 /#  ,FLL;qc"#FLL`a
&qc*
++,s   : A62A11A6