a
    bgE                     @   sL   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 deZdS )zUtil that calls Twilio.    )AnyDictOptional)get_from_dict_or_env)	BaseModel
ConfigDictmodel_validatorc                   @   s   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d	Zed
deeedddZe	e	e	dd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_numberFZforbid)Zarbitrary_types_allowedextrabefore)mode)valuesreturnc                 C   sf   zddl m} W n ty*   tdY n0 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   ZTWILIO_ACCOUNT_SIDr   ZTWILIO_AUTH_TOKENr   ZTWILIO_FROM_NUMBERr
   )Ztwilio.restr   ImportErrorr   )clsr   r   r   r    r   r/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain_community/utilities/twilio.pyvalidate_environment3   s    
z%TwilioAPIWrapper.validate_environment)bodytor   c                 C   s   | j jj|| j|d}|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.
        )Zfrom_r   )r
   messagescreater   Zsid)selfr   r   messager   r   r   runF   s    zTwilioAPIWrapper.run)__name__
__module____qualname____doc__r
   r   __annotations__r   r   strr   r   r   Zmodel_configr   classmethodr   r   r   r   r   r   r   r	   	   s   
r	   N)r#   typingr   r   r   Zlangchain_core.utilsr   Zpydanticr   r   r   r	   r   r   r   r   <module>   s   