o
    oiGB                     @  s2  d dl mZ d dlZd dlZ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 ejrddlmZmZ dd	lmZmZ dd
lmZmZ ddlmZmZ ddlmZmZ ddlm Z m!Z! ddl"m#Z#m$Z$ ddl%m&Z&m'Z' ddl(m)Z)m*Z* ddl+m,Z,m-Z- ddl.m/Z/m0Z0 G dd dZ1G dd dZ2dS )    )annotationsN   )ApiError)AsyncClientWrapperSyncClientWrapper)	LogConfigLogger)SarvamAIEnvironment)AsyncChatClient
ChatClient)AsyncDocumentIntelligenceClientDocumentIntelligenceClient)"AsyncPronunciationDictionaryClientPronunciationDictionaryClient)AsyncSpeechToTextClientSpeechToTextClient)AsyncSpeechToTextJobClientSpeechToTextJobClient) AsyncSpeechToTextStreamingClientSpeechToTextStreamingClient)#AsyncSpeechToTextTranslateJobClientSpeechToTextTranslateJobClient))AsyncSpeechToTextTranslateStreamingClient$SpeechToTextTranslateStreamingClient)AsyncTextClient
TextClient)AsyncTextToSpeechClientTextToSpeechClient) AsyncTextToSpeechStreamingClientTextToSpeechStreamingClientc                   @     e Zd ZdZejedddddddd,ddZe	dd Z
e	dd Ze	dd Ze	dd Ze	dd Ze	d d! Ze	d"d# Ze	d$d% Ze	d&d' Ze	d(d) Ze	d*d+ ZdS )-SarvamAIam  
    Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.

    Parameters
    ----------
    environment : SarvamAIEnvironment
        The environment to use for requests from the client. from .environment import SarvamAIEnvironment



        Defaults to SarvamAIEnvironment.PRODUCTION



    api_subscription_key : typing.Optional[str]
    headers : typing.Optional[typing.Dict[str, str]]
        Additional headers to send with every request.

    timeout : typing.Optional[float]
        The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.

    follow_redirects : typing.Optional[bool]
        Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.

    httpx_client : typing.Optional[httpx.Client]
        The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.

    logging : typing.Optional[typing.Union[LogConfig, Logger]]
        Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.

    Examples
    --------
    from sarvamai import SarvamAI

    client = SarvamAI(
        api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
    )
    SARVAM_API_KEYNTenvironmentapi_subscription_keyheaderstimeoutfollow_redirectshttpx_clientloggingr$   r	   r%   typing.Optional[str]r&   &typing.Optional[typing.Dict[str, str]]r'   typing.Optional[float]r(   typing.Optional[bool]r)   typing.Optional[httpx.Client]r*   0typing.Optional[typing.Union[LogConfig, Logger]]c          	      C     |d ur|n	|d u rdn|j j}|d u rtddt||||d ur#|n|d ur.tj||dntj|d||d| _d | _d | _d | _	d | _
d | _d | _d | _d | _d | _d | _d | _d S N<   zcThe client must be instantiated be either passing in api_subscription_key or setting SARVAM_API_KEY)body)r'   r(   )r'   )r$   r%   r&   r)   r'   r*   )r'   readr   r   httpxClient_client_wrapper_text_speech_to_text_text_to_speech_pronunciation_dictionary_chat_speech_to_text_job_speech_to_text_translate_job_document_intelligence_speech_to_text_streaming#_speech_to_text_translate_streaming_text_to_speech_streaming	selfr$   r%   r&   r'   r(   r)   r*   _defaulted_timeout rG   h/home/aiteam/pcaa-dev/call-proccessing/stt_pipeline/venv/lib/python3.10/site-packages/sarvamai/client.py__init__G   :   

zSarvamAI.__init__c                 C  *   | j d u rddlm} || jd| _ | j S )Nr   )r   client_wrapper)r9   text.clientr   r8   )rE   r   rG   rG   rH   textq      
zSarvamAI.textc                 C  rK   )Nr   )r   rL   )r:   speech_to_text.clientr   r8   )rE   r   rG   rG   rH   speech_to_texty   rP   zSarvamAI.speech_to_textc                 C  rK   )Nr   )r   rL   )r;   text_to_speech.clientr   r8   )rE   r   rG   rG   rH   text_to_speech   rP   zSarvamAI.text_to_speechc                 C  rK   )Nr   )r   rL   )r<   pronunciation_dictionary.clientr   r8   )rE   r   rG   rG   rH   pronunciation_dictionary   rP   z!SarvamAI.pronunciation_dictionaryc                 C  rK   )Nr   )r   rL   )r=   chat.clientr   r8   )rE   r   rG   rG   rH   chat   rP   zSarvamAI.chatc                 C  rK   )Nr   )r   rL   )r>   speech_to_text_job.clientr   r8   )rE   r   rG   rG   rH   speech_to_text_job   rP   zSarvamAI.speech_to_text_jobc                 C  rK   )Nr   )r   rL   )r?   #speech_to_text_translate_job.clientr   r8   )rE   r   rG   rG   rH   speech_to_text_translate_job   rP   z%SarvamAI.speech_to_text_translate_jobc                 C  rK   )Nr   )r   rL   )r@   document_intelligence.clientr   r8   )rE   r   rG   rG   rH   document_intelligence   rP   zSarvamAI.document_intelligencec                 C  rK   )Nr   )r   rL   )rA   speech_to_text_streaming.clientr   r8   )rE   r   rG   rG   rH   speech_to_text_streaming   rP   z!SarvamAI.speech_to_text_streamingc                 C  rK   )Nr   )r   rL   )rB   )speech_to_text_translate_streaming.clientr   r8   )rE   r   rG   rG   rH   "speech_to_text_translate_streaming      
z+SarvamAI.speech_to_text_translate_streamingc                 C  rK   )Nr   )r   rL   )rC   text_to_speech_streaming.clientr   r8   )rE   r   rG   rG   rH   text_to_speech_streaming   rP   z!SarvamAI.text_to_speech_streaming)r$   r	   r%   r+   r&   r,   r'   r-   r(   r.   r)   r/   r*   r0   __name__
__module____qualname____doc__r	   
PRODUCTIONosgetenvrI   propertyrO   rR   rT   rV   rX   rZ   r\   r^   r`   rb   re   rG   rG   rG   rH   r!      s@    **









	r!   c                   @  r    )-AsyncSarvamAIa|  
    Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.

    Parameters
    ----------
    environment : SarvamAIEnvironment
        The environment to use for requests from the client. from .environment import SarvamAIEnvironment



        Defaults to SarvamAIEnvironment.PRODUCTION



    api_subscription_key : typing.Optional[str]
    headers : typing.Optional[typing.Dict[str, str]]
        Additional headers to send with every request.

    timeout : typing.Optional[float]
        The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.

    follow_redirects : typing.Optional[bool]
        Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.

    httpx_client : typing.Optional[httpx.AsyncClient]
        The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.

    logging : typing.Optional[typing.Union[LogConfig, Logger]]
        Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.

    Examples
    --------
    from sarvamai import AsyncSarvamAI

    client = AsyncSarvamAI(
        api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
    )
    r"   NTr#   r$   r	   r%   r+   r&   r,   r'   r-   r(   r.   r)   "typing.Optional[httpx.AsyncClient]r*   r0   c          	      C  r1   r2   )r'   r5   r   r   r6   AsyncClientr8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rG   rG   rH   rI      rJ   zAsyncSarvamAI.__init__c                 C  rK   )Nr   )r   rL   )r9   rN   r   r8   )rE   r   rG   rG   rH   rO     rP   zAsyncSarvamAI.textc                 C  rK   )Nr   )r   rL   )r:   rQ   r   r8   )rE   r   rG   rG   rH   rR   &  rP   zAsyncSarvamAI.speech_to_textc                 C  rK   )Nr   )r   rL   )r;   rS   r   r8   )rE   r   rG   rG   rH   rT   .  rP   zAsyncSarvamAI.text_to_speechc                 C  rK   )Nr   )r   rL   )r<   rU   r   r8   )rE   r   rG   rG   rH   rV   6  rP   z&AsyncSarvamAI.pronunciation_dictionaryc                 C  rK   )Nr   )r
   rL   )r=   rW   r
   r8   )rE   r
   rG   rG   rH   rX   >  rP   zAsyncSarvamAI.chatc                 C  rK   )Nr   )r   rL   )r>   rY   r   r8   )rE   r   rG   rG   rH   rZ   F  rP   z AsyncSarvamAI.speech_to_text_jobc                 C  rK   )Nr   )r   rL   )r?   r[   r   r8   )rE   r   rG   rG   rH   r\   N  rc   z*AsyncSarvamAI.speech_to_text_translate_jobc                 C  rK   )Nr   )r   rL   )r@   r]   r   r8   )rE   r   rG   rG   rH   r^   X  rP   z#AsyncSarvamAI.document_intelligencec                 C  rK   )Nr   )r   rL   )rA   r_   r   r8   )rE   r   rG   rG   rH   r`   `  rP   z&AsyncSarvamAI.speech_to_text_streamingc                 C  rK   )Nr   )r   rL   )rB   ra   r   r8   )rE   r   rG   rG   rH   rb   h  s   
z0AsyncSarvamAI.speech_to_text_translate_streamingc                 C  rK   )Nr   )r   rL   )rC   rd   r   r8   )rE   r   rG   rG   rH   re   t  rP   z&AsyncSarvamAI.text_to_speech_streaming)r$   r	   r%   r+   r&   r,   r'   r-   r(   r.   r)   rp   r*   r0   rf   rG   rG   rG   rH   ro      s@    **






	


ro   )3
__future__r   rl   typingr6   core.api_errorr   core.client_wrapperr   r   core.loggingr   r   r$   r	   TYPE_CHECKINGrW   r
   r   r]   r   r   rU   r   r   rQ   r   r   rY   r   r   r_   r   r   r[   r   r   ra   r   r   rN   r   r   rS   r   r   rd   r   r   r!   ro   rG   rG   rG   rH   <module>   s.    .