Ë
    uPêjF  ã                   ó’   — d dl Z d dlmZ d dl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mZ d dlmZmZ d	d
lmZ  G d„ de«      Zy)é    N)ÚFinal)ÚHeadersÚResponse)ÚAudioTranscriptionRequestDataÚBaseAudioTranscriptionConfig)ÚBaseLLMException)Úget_secret_str)ÚAllMessageValuesÚ&OpenAIAudioTranscriptionOptionalParams)Ú	FileTypesÚTranscriptionResponseé   ©ÚOpenAIErrorc                   ó  — e Zd Z	 ddedz  dedz  dededededz  defd	„Zdedee   fd
„Z	dededededef
d„Z
	 	 ddededee   dedededz  dedz  defd„Zdededededef
d„Zdededeez  defd„Zdedefd„Zy)Ú%OpenAIWhisperAudioTranscriptionConfigNÚapi_baseÚapi_keyÚmodelÚoptional_paramsÚlitellm_paramsÚstreamÚreturnc                 ót   — |r|j                  d«      nd}|r|j                  d«      r|› d�}n|› d�}|xs dS )z{
        OPTIONAL

        Get the complete url for the request

        Some providers need `model` in `api_base`
        ú/Ú z/v1z/audio/transcriptionsz/v1/audio/transcriptions)ÚrstripÚendswith)Úselfr   r   r   r   r   r   s          ú~/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/llms/openai/transcriptions/whisper_transformation.pyÚget_complete_urlz6OpenAIWhisperAudioTranscriptionConfig.get_complete_url   sL   € ñ$ ,4�8—?‘? 3Ô'¸ˆñ ˜×)Ñ)¨%Ô0Ø"˜Ð#8Ð9‰Hà"˜Ð#;Ð<ˆHàŠ~˜2Ðó    c                 ó
   — g d¢S )zL
        Get the supported OpenAI params for the `whisper-1` models
        )ÚlanguageÚpromptÚresponse_formatÚtemperatureÚtimestamp_granularities© )r   r   s     r    Úget_supported_openai_paramszAOpenAIWhisperAudioTranscriptionConfig.get_supported_openai_params2   s   € ò
ð 	
r"   Únon_default_paramsÚdrop_paramsc                 ól   — | j                  |«      }|j                  «       D ]  \  }}||v sŒ|||<   Œ |S )z=
        Map the OpenAI params to the Whisper params
        )r*   Úitems)r   r+   r   r   r,   Úsupported_paramsÚkÚvs           r    Úmap_openai_paramsz7OpenAIWhisperAudioTranscriptionConfig.map_openai_params>   sL   € ð #'×"BÑ"BÀ5Ó"IÐØ&×,Ñ,Ó.ò 	'‰DˆAˆqØÐ$Ò$Ø%&� Ò"ð	'ð Ðr"   ÚheadersÚmessagesc                 óT   — |xs t        d«      }dd|› �i}|j                  |«       |S )NÚOPENAI_API_KEYÚAuthorizationzBearer )r	   Úupdate)	r   r3   r   r4   r   r   r   r   Úauth_headers	            r    Úvalidate_environmentz:OpenAIWhisperAudioTranscriptionConfig.validate_environmentN   s<   € ð Ò=œ^Ð,<Ó=ˆð ˜w w iÐ0ð
ˆð 	�‰�{Ô#Øˆr"   Ú
audio_filec                 ó:   — ||dœ|¥}d|vrd|d<   t        |¬«      S )z;
        Transform the audio transcription request
        )r   Úfiler&   Úverbose_json)Údata)r   )r   r   r;   r   r   r?   s         r    Ú%transform_audio_transcription_requestzKOpenAIWhisperAudioTranscriptionConfig.transform_audio_transcription_requesta   s6   € ð !&¨zÑM¸_ÐMˆà DÑ(Ø&4ˆDÐ"Ñ#ä,Øô
ð 	
r"   Úerror_messageÚstatus_codec                 ó   — t        |||¬«      S )N)rB   Úmessager3   r   )r   rA   rB   r3   s       r    Úget_error_classz5OpenAIWhisperAudioTranscriptionConfig.get_error_classt   s   € ÜØ#Ø!Øô
ð 	
r"   Úraw_responsec                 óT  ‡— 	 |j                  «       Št        ˆfd„t
        j                  D «       «      rt        di ‰¤ŽS t        d‰«      ‚# t         j                  $ rH |j                  j                  dd«      j	                  «       }d|v r‚ t        |j                  ¬«      cY S w xY w)Nzcontent-typer   zapplication/json)Útextc              3   ó&   •K  — | ]  }|‰v –— Œ
 y ­w©Nr)   )Ú.0ÚkeyÚraw_response_jsons     €r    ú	<genexpr>z_OpenAIWhisperAudioTranscriptionConfig.transform_audio_transcription_response.<locals>.<genexpr>‡   s   øè ø€ ÒV¨CˆsÐ'Ô'ÑVùs   ƒzTInvalid response format. Received response does not match the expected format. Got: r)   )
ÚjsonÚJSONDecodeErrorr3   ÚgetÚlowerr   rH   ÚanyÚmodel_fieldsÚ
ValueError)r   rF   Úcontent_typerM   s      @r    Ú&transform_audio_transcription_responsezLOpenAIWhisperAudioTranscriptionConfig.transform_audio_transcription_response{   s§   ø€ ð	AØ'3×'8Ñ'8Ó':Ðô ÓVÔ3H×3UÑ3UÔVÔVÜ(Ñ=Ð+<Ñ=Ð=äØfØ!óð øô ×#Ñ#ò 	AØ".×"6Ñ"6×":Ñ":¸>È2Ó"N×"TÑ"TÓ"VˆLØ! \Ñ1ØÜ(¨l×.?Ñ.?Ô@Ò@ð		Aús   ƒA ÁAB'Â&B'rJ   )NN)Ú__name__Ú
__module__Ú__qualname__ÚstrÚdictÚboolr!   Úlistr   r*   r2   r
   r:   r   r   r@   Úintr   r   rE   r   r   rW   r)   r"   r    r   r      s†  „ ð #ñà˜‘*ðð �t‘ðð ð	ð
 ðð ðð �t‘ðð 
óð8

°ð 

¸Ð>dÑ9eó 

ðà ðð ðð ð	ð
 ðð 
óð. #Ø#ñàðð ðð Ð'Ñ(ð	ð
 ðð ðð �t‘ðð ˜‘*ðð 
óð&
àð
ð ð
ð ð	
ð
 ð
ð 
'ó
ð&
¨Sð 
¸sð 
ÈTÐT[É^ð 
Ð`pó 
ðàðð 
ôr"   r   )rO   Útypingr   Úhttpxr   r   Ú8litellm.llms.base_llm.audio_transcription.transformationr   r   Ú)litellm.llms.base_llm.chat.transformationr   Úlitellm.secret_managers.mainr	   Úlitellm.types.llms.openair
   r   Úlitellm.types.utilsr   r   Úcommon_utilsr   r   r)   r"   r    ú<module>rh      s9   ðÛ Ý ç #÷õ GÝ 7÷÷ Aå &ôxÐ,Hõ xr"   