o
    Ã¿i=
  ã                
   @   s¤   d Z ddlmZ ddlmZ ddlmZ zddlmZ	 W n  e
y< Z ze de› ¡ e d¡ ede› ƒ‚d	Z[ww eG d
d„ dejƒƒZG dd„ deƒZd	S )z1Azure OpenAI Realtime LLM service implementation.é    )Ú	dataclass)Úlogger)ÚOpenAIRealtimeLLMService)ÚconnectzException: zMIn order to use Azure Realtime, you need to `pip install pipecat-ai[openai]`.zMissing module: Nc                   @   s   e Zd ZdZdS )ÚAzureRealtimeLLMSettingsz%Settings for AzureRealtimeLLMService.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   úW/home/ubuntu/.local/lib/python3.10/site-packages/pipecat/services/azure/realtime/llm.pyr      s    r   c                       s@   e Zd ZU dZeZeed< dedef‡ fdd„Zdd„ Z	‡  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                   s(   t ƒ jd||dœ|¤Ž || _|| _dS )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__r   r   r   )   s   
z AzureRealtimeLLMService.__init__c              
   Ã   sš   z(| j rW d S t d| j› ¡ t| jd| jidI d H | _ |  |  ¡ ¡| _W d S  t	yL } z| j
d|› |dI d H  d | _ W Y d }~d S d }~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   Úer   r   r   Ú_connect<   s    €ÿþ€þz AzureRealtimeLLMService._connect)r   r   r	   r
   r   ÚSettingsÚ__annotations__Ústrr   r$   Ú__classcell__r   r   r   r   r      s   
 ýür   )r
   Údataclassesr   Úlogurur   Ú$pipecat.services.openai.realtime.llmr   Úwebsockets.asyncio.clientr   r   ÚModuleNotFoundErrorr#   Úerrorr!   r%   r   r   r   r   r   r   Ú<module>   s   
€ý