o
    i.H                     @   s   d Z ddlmZ ddlmZ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 dd	lmZmZmZmZ G d
d deZdS )zACode generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.   )BaseSDK    )modelsutils)HookContext)OptionalNullableUNSET)eventstreamingget_security_from_env)unmarshal_json_response)ListMappingOptionalUnionc                   @   s|  e Zd ZdZdeeeededddd
dedeeej	ej
f  dee dee dee d	ee d
eeej  deej dee dee deeeef  dejfddZdeeeededddd
dedeeej	ej
f  dee dee dee d	ee d
eeej  deej dee dee deeeef  dejfddZdeeeededddd
dedeeej	ej
f  dee dee dee d	ee d
eeej  deej dee dee deeeef  dejej fddZdeeeededddd
dedeeej	ej
f  dee dee dee d	ee d
eeej  deej dee dee deeeef  dejej fddZdS )TranscriptionszAPI for audio transcription.N)
filefile_urlfile_idlanguagetemperaturetimestamp_granularitiesretries
server_url
timeout_mshttp_headersmodelr   r   r   r   r   r   r   r   r   r   returnc                   sj  d}d}|
du r| j j}
|	dur|	}n| ||}tj|t|ttj |||||d | j	dd|| ddddd|| j j
 fd	d
|
d}|tkrS| j jturS| j j}d}t|tjra|g df}| jt| j |piddg t| j j
tjd|ddg|d}t|ddrttj|S t|ddrt|}td||t|ddrt|}td||td|)  Create Transcription

        :param model:
        :param file:
        :param file_url: Url of a file to be transcribed
        :param file_id: ID of a file uploaded to /v1/files
        :param language: Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
        :param temperature:
        :param timestamp_granularities: Granularities of timestamps to include in the response.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        Nr   r   r   r   r   r   r   POST/v1/audio/transcriptionsTF
user-agentapplication/jsonc                         t  dddtjS NF	multipartr   serialize_request_bodyr   AudioTranscriptionRequest requestr)   ^/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/mistralai/transcriptions.py<lambda>M       z)Transcriptions.complete.<locals>.<lambda>methodpathbase_urlurl_variablesr+   request_body_requiredrequest_has_path_paramsrequest_has_query_paramsuser_agent_headeraccept_header_valuer   securityget_serialized_bodyr   429500502503504  audio_api_v1_transcriptions_postconfigr2   operation_idoauth2_scopessecurity_source4XX5XXhook_ctxr+   error_status_codesretry_config200*API error occurredUnexpected response received)sdk_configurationr   _get_urlr   r(   r   get_pydantic_modelr   File_build_requestr9   r   rM   
isinstanceRetryConfig
do_requestr   r
   Securitymatch_responser   TranscriptionResponsestream_to_textSDKErrorselfr   r   r   r   r   r   r   r   r   r   r   r2   r3   reqrM   http_reshttp_res_textr)   r*   r,   complete   sz   


	

zTranscriptions.completec                   s~  d}d}|
du r| j j}
|	dur|	}n| ||}tj|t|ttj |||||d | j	dd|| ddddd|| j j
 fd	d
|
d}|tkrT| j jturT| j j}d}t|tjrb|g df}| jt| j |pjddg t| j j
tjd|ddg|dI dH }t|ddrttj|S t|ddrt|I dH }td||t|ddrt|I dH }td||td|)r   Nr   r   r    TFr!   r"   c                      r#   r$   r&   r)   r*   r)   r,   r-      r.   z/Transcriptions.complete_async.<locals>.<lambda>r/   r;   rA   rB   rC   rH   rI   rJ   rN   rO   rP   rQ   )rR   r   rS   r   r(   r   rT   r   rU   _build_request_asyncr9   r   rM   rW   rX   do_request_asyncr   r
   rZ   r[   r   r\   stream_to_text_asyncr^   r_   r)   r*   r,   complete_asyncu   s|   


	zTranscriptions.complete_asyncc                   s  d}d}|
du r| j j}
|	dur|	}n| ||}tj|t|ttj |||||d | j	dd|| ddddd|| j j
 fd	d
|
d}|tkrS| j jturS| j j}d}t|tjra|g df}| jt| j |piddg t| j j
tjd|ddgd|d}t|ddrtj|dd
 | dS t|ddrt|}td||t|ddrt|}td||t|}td||)  Create streaming transcription (SSE)

        :param model:
        :param file:
        :param file_url: Url of a file to be transcribed
        :param file_id: ID of a file uploaded to /v1/files
        :param language: Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
        :param temperature:
        :param timestamp_granularities: Granularities of timestamps to include in the response.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        Nr   r   /v1/audio/transcriptions#streamTFr!   text/event-streamc                      r#   r$   r   r'   r   AudioTranscriptionRequestStreamr)   r*   r)   r,   r-         z'Transcriptions.stream.<locals>.<lambda>r/   r;   rA   'audio_api_v1_transcriptions_post_streamrC   rH   rI   rK   r+   rL   streamrM   rN   c                 S      t | tjS Nr   unmarshal_jsonr   TranscriptionStreamEventsrawr)   r)   r,   r-   >      
client_refrO   rP   rQ   )rR   r   rS   r   rm   r   rT   r   rU   rV   r9   r   rM   rW   rX   rY   r   r
   rZ   r[   r	   EventStreamr]   r^   r_   r)   r*   r,   rq      s   


	


zTranscriptions.streamc                   s  d}d}|
du r| j j}
|	dur|	}n| ||}tj|t|ttj |||||d | j	dd|| ddddd|| j j
 fd	d
|
d}|tkrT| j jturT| j j}d}t|tjrb|g df}| jt| j |pjddg t| j j
tjd|ddgd|dI dH }t|ddrtj|dd
 | dS t|ddrt|I dH }td||t|ddrt|I dH }td||t|I dH }td||)ri   Nr   r   rj   TFr!   rk   c                      r#   r$   rl   r)   r*   r)   r,   r-     rn   z-Transcriptions.stream_async.<locals>.<lambda>r/   r;   rA   ro   rC   rH   rI   rp   rN   c                 S   rr   rs   rt   rw   r)   r)   r,   r-     ry   rz   rO   rP   rQ   )rR   r   rS   r   rm   r   rT   r   rU   re   r9   r   rM   rW   rX   rf   r   r
   rZ   r[   r	   EventStreamAsyncrg   r^   r_   r)   r*   r,   stream_asyncK  s   


	zTranscriptions.stream_async)__name__
__module____qualname____doc__r   strr   r   r   rU   FileTypedDictr   floatr   TimestampGranularityr   rX   intr   r\   rd   rh   r	   r|   rv   rq   r}   r~   r)   r)   r)   r,   r      s   	

j	

j	


t	

r   N)r   basesdkr   	mistralair   r   mistralai._hooksr   mistralai.typesr   r   mistralai.utilsr	   r
   'mistralai.utils.unmarshal_json_responser   typingr   r   r   r   r   r)   r)   r)   r,   <module>   s    