
    oiJ                        d dl mZ 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
 ddlmZmZmZmZmZ ddlmZ dd	lmZmZmZmZmZmZmZmZmZmZmZmZ dd
lmZmZm Z  ddlm!Z!m"Z"m#Z#m$Z$ ddlm%Z%m&Z&m'Z'm(Z(m)Z) ddlm*Z*m+Z+m,Z,m-Z- ddlm.Z.m/Z/ ddlm0Z0m1Z1 ddlm2Z2m3Z3m4Z4 ddlm5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z< ddlm=Z=m>Z>m?Z? ddlm@Z@mAZA ddlmBZBmCZC ddlmDZDmEZE ddlmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZW ddlmXZXmYZY ddlmZZZm[Z[ ddlm\Z\m]Z]m^Z^ ddlm_Z_m`Z`maZambZbmcZcmdZd ddlmeZemfZfmgZgmhZhmiZi ddlmjZjmkZkmlZl ddlmmZmmnZn ddlmoZompZp ddlmqZq dd lmrZrmsZsmtZtmuZu dd!lmvZvmwZwmxZxmyZy dd"lmzZzm{Z{ dd#lm|Z| dd$lm}Z}m~Z~ dd%lmZmZmZmZmZmZmZ dd&lmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ dd'lmZmZmZmZ dd(lmZ dd)lmZmZ dd*lmZmZmZmZmZmZmZmZmZmZ dd+lmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ dd,lmZmZ dd-lmZ  G d. d/      Z G d0 d1      Zy)2    )Optional)import_moduleN   )__version__)verboselogs)
TextSourceBufferSourceStreamSource
FileSource	UrlSource)BaseResponse)AverageIntentIntentsIntentsInfoSegmentSentimentInfo	Sentiment
SentimentsSummaryInfoTopicTopics
TopicsInfo)	ModelInfoHitSearch)OpenResponseCloseResponseUnhandledResponseErrorResponse)DeepgramErrorDeepgramTypeErrorDeepgramModuleErrorDeepgramApiErrorDeepgramUnknownApiError)ListenRouter
ReadRouterSpeakRouterAgentRouter)
LiveClientAsyncLiveClient)ListenWebSocketClientAsyncListenWebSocketClient)ListenWebSocketOptionsLiveOptionsLiveTranscriptionEvents)LiveResultResponseListenWSMetadataResponseSpeechStartedResponseUtteranceEndResponseListenWSMetadataListenWSAlternativeListenWSChannelListenWSWord)PreRecordedStreamSourcePrerecordedSourceListenRestSource)PreRecordedClientAsyncPreRecordedClient)ListenRESTClientAsyncListenRESTClient)ListenRESTOptionsPrerecordedOptions)AsyncPrerecordedResponsePrerecordedResponseSyncPrerecordedResponseEntityListenRESTMetadata	Paragraph
ParagraphsListenRESTResultsSentence	Summaries	SummaryV1	SummaryV2Translation	UtteranceWarningListenRESTAlternativeListenRESTChannelListenRESTWord)
ReadClientAsyncReadClient)AnalyzeClientAsyncAnalyzeClient)AnalyzeOptionsAnalyzeStreamSourceAnalyzeSource)AsyncAnalyzeResponseSyncAnalyzeResponseAnalyzeResponseAnalyzeMetadataAnalyzeResultsAnalyzeSummary)SpeakRESTOptionsSpeakOptionsSpeakSourceSpeakRestSourceSpeakRESTSource)SpeakClientSpeakRESTClientAsyncSpeakRESTClient)SpeakResponseSpeakRESTResponse)SpeakWebSocketEventsSpeakWebSocketMessage)SpeakWSOptions)SpeakWebSocketClientAsyncSpeakWebSocketClientSpeakWSClientAsyncSpeakWSClient)SpeakWSMetadataResponseFlushedResponseClearedResponseWarningResponse)AuthRESTClientAsyncAuthRESTClient)GrantTokenResponse)ManageClientAsyncManageClient)ProjectOptions
KeyOptionsScopeOptionsInviteOptionsUsageRequestOptionsUsageSummaryOptionsUsageFieldsOptions)"MessageProjectsResponseModelResponseModelsResponseMembersResponseKeyResponseKeysResponseScopesResponseInvitesResponseUsageRequestUsageResponseUsageRequestsResponseUsageSummaryResponseUsageFieldsResponseBalancesResponseProject
STTDetailsTTSMetadata
TTSDetailsMemberKeyInviteConfigSTTUsageDetailsCallbackTokenDetailSpeechSegmentTTSUsageDetails	STTTokens	TTSTokensUsageSummaryResults
Resolution
UsageModelBalance)OnPremClientAsyncOnPremClientSelfHostedClientAsyncSelfHostedClient)AgentWebSocketEvents)AgentWebSocketClientAsyncAgentWebSocketClient)
WelcomeResponseSettingsAppliedResponseConversationTextResponseUserStartedSpeakingResponseAgentThinkingResponseFunctionCallFunctionCallRequestAgentStartedSpeakingResponseAgentAudioDoneResponseInjectionRefusedResponse)SettingsOptionsUpdatePromptOptionsUpdateSpeakOptionsInjectAgentMessageOptionsInjectUserMessageOptionsFunctionCallResponseAgentKeepAliveListenSpeakHeaderItem
Properties
ParametersFunctionThinkProviderAgentInputOutputAudioEndpoint)DeepgramClientOptionsClientOptionsFromEnv)DeepgramApiKeyErrorc                       e Zd ZdZd Zy)DeepgramzK
    The Deepgram class is no longer a class in version 3 of this SDK.
    c                     t        d      )Na  
            FATAL ERROR:
            You are attempting to instantiate a Deepgram object, which is no longer a class in version 3 of this SDK.

            To fix this issue:
                1. You need to revert to the previous version 2 of the SDK: pip install deepgram-sdk==2.12.0
                2. or, update your application's code to use version 3 of this SDK. See the README for more information.

            Things to consider:

                - This Version 3 of the SDK requires Python 3.10 or higher.
                  Older versions (3.9 and lower) of Python are nearing end-of-life: https://devguide.python.org/versions/
                  Understand the risks of using a version of Python nearing EOL.

                - Version 2 of the SDK will receive maintenance updates in the form of security fixes only.
                  No new features will be added to version 2 of the SDK.
            )	Exception)selfanythings     b/home/ccuser/rateright-growth/voice-assistant/venv/lib/python3.12/site-packages/deepgram/client.py__init__zDeepgram.__init__  s    
 	
    N)__name__
__module____qualname____doc__r    r   r   r   r   ~  s    
r   r   c                      e Zd ZU dZeed<   ej                  ed<   	 	 	 ddede	e   defdZ
ed	        Zed
        Zed        Ze ej                   dded      d               Zed        Zed        Zed        Zed        Ze ej                   dded      d               Zed        Ze ej                   dded      d               Zed        Zed        Z G d d      Zy)DeepgramClientaY  
    Represents a client for interacting with the Deepgram API.

    This class provides a client for making requests to the Deepgram API with various configuration options.

    Attributes:
        api_key (str): The Deepgram API key used for authentication.
        access_token (str): The Deepgram access token used for authentication.
        config_options (DeepgramClientOptions): An optional configuration object specifying client options.

    Raises:
        DeepgramApiKeyError: If both API key and access token are missing or invalid.

    Methods:
        listen: Returns a ListenClient instance for interacting with Deepgram's transcription services.

        manage: (Preferred) Returns a Threaded ManageClient instance for managing Deepgram resources.
        selfhosted: (Preferred) Returns an Threaded SelfHostedClient instance for interacting with Deepgram's on-premises API.

        asyncmanage: Returns an (Async) ManageClient instance for managing Deepgram resources.
        asyncselfhosted: Returns an (Async) SelfHostedClient instance for interacting with Deepgram's on-premises API.
    _config_loggerNapi_keyconfigaccess_tokenc                 ,   t        j                  t              | _        | j                  j	                  t        j                                |r|nd}|r|nd}|dk(  r:|dk(  r5|3| j                  j                  d       |j                  }|j                  }|dk(  rQ|dk(  rL| j                  j                  d       t        j                  dd      }|dk(  rt        j                  dd      }|dk(  r |dk(  r| j                  j                  d       |t        ||      | _        n8|r|dk7  r|j                  |       n|r|dk7  r|j!                  |       || _        | j                  j                  | _        | j                  j                  | _	        y )N z0Attempting to set credentials from config objectz8Attempting to get credentials from environment variablesDEEPGRAM_ACCESS_TOKENDEEPGRAM_API_KEYz5WARNING: Neither API key nor access token is provided)r   r   )r   VerboseLoggerr   r   
addHandlerloggingStreamHandlerinfor   r   osgetenvwarningr   r   
set_apikeyset_access_token)r   r   r   r   s       r   r   zDeepgramClient.__init__  so    #00: 5 5 78 %'"'3| b=\R/F4FLLBDnnG!..L b=\R/LLJ 99%<bALr!))$6; b=\R/LL  G >0lDL 7b=!!'*,""4''5!DL ||++ LL55r   c                 ,    t        | j                        S )zn
        Returns a Listen dot-notation router for interacting with Deepgram's transcription services.
        )r&   r   r   s    r   listenzDeepgramClient.listen  s    
 DLL))r   c                 ,    t        | j                        S )zc
        Returns a Read dot-notation router for interacting with Deepgram's read services.
        )r'   r   r   s    r   readzDeepgramClient.read  s    
 $,,''r   c                 ,    t        | j                        S )ze
        Returns a Speak dot-notation router for interacting with Deepgram's speak services.
        )r(   r   r   s    r   speakzDeepgramClient.speak      
 4<<((r   z3.4.0z4.0.0zHdeepgram.asyncspeak is deprecated. Use deepgram.speak.asyncrest instead.)deprecated_in
removed_incurrent_versiondetailsc                 :    | j                  | j                  d      S )zf
        DEPRECATED: deepgram.asyncspeak is deprecated. Use deepgram.speak.asyncrest instead.
        
asyncspeakVersionr   r   s    r   r   zDeepgramClient.asyncspeak       ||DLL,77r   c                 :    | j                  | j                  d      S )zR
        Returns a ManageClient instance for managing Deepgram resources.
        manager   r   s    r   r  zDeepgramClient.manage  s    
 ||DLL(33r   c                 :    | j                  | j                  d      S )zX
        Returns an AsyncManageClient instance for managing Deepgram resources.
        asyncmanager   r   s    r   r  zDeepgramClient.asyncmanage  s    
 ||DLL-88r   c                 :    | j                  | j                  d      S )zU
        Returns an AuthRESTClient instance for managing short-lived tokens.
        authr   r   s    r   r  zDeepgramClient.auth  s    
 ||DLL&11r   c                 :    | j                  | j                  d      S )zZ
        Returns an AsyncAuthRESTClient instance for managing short-lived tokens.
        	asyncauthr   r   s    r   r  zDeepgramClient.asyncauth!  s    
 ||DLL+66r   zEdeepgram.onprem is deprecated. Use deepgram.speak.selfhosted instead.c                 :    | j                  | j                  d      S )zc
        DEPRECATED: deepgram.onprem is deprecated. Use deepgram.speak.selfhosted instead.
        
selfhostedr   r   s    r   onpremzDeepgramClient.onprem(  r   r   c                 :    | j                  | j                  d      S )zg
        Returns an SelfHostedClient instance for interacting with Deepgram's on-premises API.
        r
  r   r   s    r   r
  zDeepgramClient.selfhosted5  s    
 ||DLL,77r   zOdeepgram.asynconprem is deprecated. Use deepgram.speak.asyncselfhosted instead.c                 :    | j                  | j                  d      S )zm
        DEPRECATED: deepgram.asynconprem is deprecated. Use deepgram.speak.asyncselfhosted instead.
        asyncselfhostedr   r   s    r   asynconpremzDeepgramClient.asynconprem<  s     ||DLL*;<<r   c                 :    | j                  | j                  d      S )zl
        Returns an AsyncSelfHostedClient instance for interacting with Deepgram's on-premises API.
        r  r   r   s    r   r  zDeepgramClient.asyncselfhostedI  s    
 ||DLL*;<<r   c                 ,    t        | j                        S )ze
        Returns a Agent dot-notation router for interacting with Deepgram's speak services.
        )r)   r   r   s    r   agentzDeepgramClient.agentP  r   r   c                   ^    e Zd ZU dZej
                  ed<   eed<   eed<   defdZ	d
defdZ
y	)DeepgramClient.Versionz;
        Represents a version of the Deepgram API.
        r   r   _parentparentc                     t        j                  t              | _        | j                  j	                  t        j                                | j                  j                  |j                         || _	        || _
        y )N)r   r   r   r   r   r   r   setLevelverboser   r  )r   r   r  s      r   r   zDeepgramClient.Version.__init__a  sS    &44X>DLLL##G$9$9$;<LL!!&..1!DL!DLr   versionc                    | j                   j                  d       | j                   j                  d|       t        |      dk(  rA| j                   j	                  d       | j                   j                  d       t        d      d}d}d}| j                  xdk(  r d}d	}d
}nxdk(  r d}d}d}nxdk(  r t        | j                        S xdk(  r d}d	}d}nrxdk(  r d}d}d}nexdk(  r d}d	}d}nXdk(  rd}d}d}nM	 | j                   j	                  d| j                         | j                   j                  d       t        d      d| d| d| }| j                   j                  d|       | j                   j                  d|       t        |      }|A| j                   j	                  d       | j                   j                  d       t        d      t        ||      }|A| j                   j	                  d        | j                   j                  d       t        d!       || j                        }| j                   j                  d"       | j                   j                  d       |S )#zP
            Returns a client for the specified version of the API.
            zVersion.v ENTERzversion: %sr   zversion is emptyzVersion.v LEAVEzInvalid module versionr   r  clientry   r  async_clientrz   r   r
  r   r  r   r  rv   r  rw   zparent unknown: %szInvalid parent typezdeepgram.clients.z.v.zpath: %szclassname: %szmodule path is NonezUnable to find packagezmy_class is NonezUnable to find classzVersion.v succeeded)r   debugr   lenerrorr#   r  rh   r   r   getattrnotice)	r   r  r  filename	classnamepathmodmy_classmy_class_instances	            r   vzDeepgramClient.Version.vu  s>   
 LL01LLmW57|q ""#56""#45)*BCCFHI,,%F'H .I"%F-H 3I!/==!)F'H 2I&)F-H 7I#F'H 0I #F-H 5ILL&&';T\\JLL&&'89-.CDD 'vhb	8*EDLLj$/LLoy9  %C{""#89""#45)*BCCsI.H""#56""#45)*@AA !) 6LL 56LL01$$r   N)r   )r   r   r   r   r   r   __annotations__r   strr   r*  r   r   r   r   r  X  s:    	 ***&&	"3 	"(E	%S E	%r   r   )r   Nr   )r   r   r   r   r   r+  r   r   r,  r   r   propertyr   r   r   deprecation
deprecatedr   r   r  r  r  r  r  r
  r  r  r  r   r   r   r   r   r     s   . #"&&& 26	4646 ./46 	46l * * ( ( ) ) [#Z	8 8 4 4 9 9 2 2 7 7 [#W	8 8 8 8 [#a	= = = = ) )b% b%r   r   )typingr   	importlibr   r   r   r.  r   r   utilsr   clientsr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   optionsr   r   errorsr   r   r   r   r   r   <module>r6     s  
  # 	      "    
   H G 1   & ) ) ) ) )X 1 6  4   A   9
 5  % % % % % % % % %P  *
  &     8 A '

 
6a% a%r   