
    NgE                     Z    d Z ddlmZmZmZ ddlmZ ddlmZm	Z	m
Z
  G d de          ZdS )zUtil that calls Twilio.    )AnyDictOptional)get_from_dict_or_env)	BaseModel
ConfigDictmodel_validatorc                       e Zd ZU dZdZeed<   dZee	         ed<   	 dZ
ee	         ed<   	 dZee	         ed<   	  edd	          Z ed
          ededefd                        Zde	de	de	fdZdS )TwilioAPIWrappera  Messaging Client using Twilio.

    To use, you should have the ``twilio`` python package installed,
    and the environment variables ``TWILIO_ACCOUNT_SID``, ``TWILIO_AUTH_TOKEN``, and
    ``TWILIO_FROM_NUMBER``, or pass `account_sid`, `auth_token`, and `from_number` as
    named parameters to the constructor.

    Example:
        .. code-block:: python

            from langchain_community.utilities.twilio import TwilioAPIWrapper
            twilio = TwilioAPIWrapper(
                account_sid="ACxxx",
                auth_token="xxx",
                from_number="+10123456789"
            )
            twilio.run('test', '+12484345508')
    Nclientaccount_sid
auth_tokenfrom_numberFforbid)arbitrary_types_allowedextrabefore)modevaluesreturnc                     	 ddl m} n# t          $ r t          d          w xY wt          |dd          }t          |dd          }t          |dd	          |d<    |||          |d
<   |S )z?Validate that api key and python package exists in environment.r   )ClientzTCould not import twilio python package. Please install it with `pip install twilio`.r   TWILIO_ACCOUNT_SIDr   TWILIO_AUTH_TOKENr   TWILIO_FROM_NUMBERr   )twilio.restr   ImportErrorr   )clsr   r   r   r   s        `/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/utilities/twilio.pyvalidate_environmentz%TwilioAPIWrapper.validate_environment3   s    	******* 	 	 	?  	
 +6=BVWW)&,@STT
 4M#7!
 !
} "6+z::xs   	 #bodytoc                 ^    | j         j                            || j        |          }|j        S )a  Run body through Twilio and respond with message sid.

        Args:
            body: The text of the message you want to send. Can be up to 1,600
                characters in length.
            to: The destination phone number in
                [E.164](https://www.twilio.com/docs/glossary/what-e164) format for
                SMS/MMS or
                [Channel user address](https://www.twilio.com/docs/sms/channels#channel-addresses)
                for other 3rd-party channels.
        )from_r!   )r   messagescreater   sid)selfr!   r"   messages       r   runzTwilioAPIWrapper.runF   s.     +&--b8Ht-TT{    )__name__
__module____qualname____doc__r   r   __annotations__r   r   strr   r   r   model_configr	   classmethodr   r    r*    r+   r   r   r   	   s         & FC!%K#%%%+ $J$$$!%K#%%%	 : %  L
 _(###$ 3    [ $#"        r+   r   N)r/   typingr   r   r   langchain_core.utilsr   pydanticr   r   r	   r   r4   r+   r   <module>r8      s      & & & & & & & & & & 5 5 5 5 5 5 ; ; ; ; ; ; ; ; ; ;J J J J Jy J J J J Jr+   