o
    ȳgE                     @   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dedefddZde	de	de	f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_numberFforbid)arbitrary_types_allowedextrabefore)modevaluesreturnc                 C   sb   zddl m} W n ty   td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    r   `/var/www/html/chatdoc2/venv/lib/python3.10/site-packages/langchain_community/utilities/twilio.pyvalidate_environment3   s   z%TwilioAPIWrapper.validate_environmentbodytoc                 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.
        )from_r   )r
   messagescreater   sid)selfr   r    messager   r   r   runF   s   zTwilioAPIWrapper.run)__name__
__module____qualname____doc__r
   r   __annotations__r   r   strr   r   r   model_configr   classmethodr   r   r'   r   r   r   r   r	   	   s"   
 r	   N)r+   typingr   r   r   langchain_core.utilsr   pydanticr   r   r   r	   r   r   r   r   <module>   s
    