o
    ưi                     @   s   d dl mZ d dlmZmZmZmZ d dlmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZmZmZ dd	lmZ dd
lmZ G dd deZdS )    )uuid)Any	CoroutineOptionalUnion)AsyncAzureOpenAIAzureOpenAI)	BaseModel)get_audio_file_name)	FileTypes)TranscriptionResponse convert_to_model_response_object extract_duration_from_srt_or_vtt   )AzureChatCompletion)AzureOpenAIErrorc                "   @   s   e Zd Z							ddedededededed	e	d
e
e de
e de
e de
e dede
e deeeeeef f fddZ						ddedededededede
e d
e
e de
e de
e defddZdS )AzureAudioTranscriptionNFmodel
audio_fileoptional_paramslogging_objmodel_responsetimeoutmax_retriesapi_keyapi_baseapi_versionazure_ad_tokenatranscriptionlitellm_paramsreturnc                 C   s  ||d|}|du r| j ||||||	|||||dS | j|
|	||d||d}t|ts2tddd|jd	t  |jd
d|j i|j	j
d|dd |jjjdi |d|i}t|tre| }nt|d }|jt||d|i|d |dd}t|||dd}|S )N)r   fileT)r   datar   r   r   r   clientr   r   r   r   Fr   r   r   r   Z	_is_asyncr#   r     z.azure_client is not an instance of AzureOpenAIstatus_codemessageaudio_file_AuthorizationBearer headersr   r   complete_input_dictinputr   additional_argsr   textr.   r0   r   r1   original_responseazurer   Zcustom_llm_provideraudio_transcription)response_objectmodel_response_objecthidden_paramsresponse_type )async_audio_transcriptionsget_azure_openai_client
isinstancer   r   pre_callr   uuid4r   	_base_url_uri_referenceaudiotranscriptionscreater	   
model_dumpr   	post_callr
   r   )selfr   r   r   r   r   r   r   r   r   r   r#   r   r   r   r"   Zazure_clientresponsestringified_responser;   Zfinal_responser=   r=   ^/home/app/Keep/.python/lib/python3.10/site-packages/litellm/llms/azure/audio_transcriptions.pyaudio_transcriptions   sn   
	


z,AzureAudioTranscription.audio_transcriptionsr"   c              
      sl  d }z| j ||	||d|
|d}t|tstddd|jdt  |jdd|j i|jj	d|d	d
 |j
jjjdi |d|iI d H }t|j}| }t|tr[| }nt|d }t|}||d< |jt||dd|j i|jj	d|d	|d |dd}t||||dd}t|tstddd|W S  ty } z|jt|t|d |d }~ww )NTr$   r%   z9async_azure_client is not an instance of AsyncAzureOpenAIr&   r)   r*   r+   r,   r/   r   r2   Z_audio_transcription_durationr4   r6   r7   r8   )Z_response_headersr9   r:   r;   r<   z4response is not an instance of TranscriptionResponse)r0   r   r5   r=   )r?   r@   r   r   rA   r   rB   r   rC   rD   rE   rF   Zwith_raw_responserG   dictr-   parser	   rH   r   r   rI   r
   r   	Exceptionr0   str)rJ   r   r   r"   r   r   r   r   r   r   r#   r   r   rK   Zasync_azure_clientZraw_responser-   rL   durationr;   er=   r=   rM   r>   e   s   
	




z2AzureAudioTranscription.async_audio_transcriptions)NNNNNFN)NNNNNN)__name__
__module____qualname__rR   r   rO   r   r   floatintr   boolr   r   rN   r>   r=   r=   r=   rM   r      s    
	

Y	
r   N)Zlitellm._uuidr   typingr   r   r   r   Zopenair   r   Zpydanticr	   Z,litellm.litellm_core_utils.audio_utils.utilsr
   Zlitellm.types.utilsr   Zlitellm.utilsr   r   r   r6   r   Zcommon_utilsr   r   r=   r=   r=   rM   <module>   s    