Ë
    µŒjs  ã                   óª   — d dl Z d dlZd dlmZmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ dedefd	„Zd
edede
fd„Z eddd¬«       G d„ de«      «       Zy)é    N)ÚAnyÚIterator)Ú
deprecated)ÚBaseChatLoader)ÚChatSession)ÚHumanMessageÚmsgÚreturnc                 ó`  — d }| d   d   D ]  }|d   }|dk(  sŒ|d   }Œ |€t         ‚| d   d   D ]w  }|d   dk(  sŒ|d	   d
   }t        j                  |«      j                  d«      }t	        j
                  d«      }t	        j                  ||«      d   }t        |d|i¬«      }|c S  t         ‚)NÚpayloadÚheadersÚnameÚFromÚvalueÚpartsÚmimeTypez
text/plainÚbodyÚdatazutf-8z\r\nOn .+(\r\n)*wrote:\r\nr   Úsender)ÚcontentÚadditional_kwargs)Ú
ValueErrorÚbase64Úurlsafe_b64decodeÚdecodeÚreÚcompileÚsplitr   )	r	   Ú
from_emailÚvaluesr   Úpartr   ÚpatternÚnewest_responseÚmessages	            úp/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/chat_loaders/gmail.pyÚ_extract_email_contentr&      sÓ   € Ø€JØ�i‘. Ô+ˆØ�f‰~ˆØ�6‹>Ø ™‰Jð ,ð ÐÜÐØ�I‘˜wÔ'ˆØ�
Ñ˜|Ó+Ø˜‘< Ñ'ˆDÜ×+Ñ+¨DÓ1×8Ñ8¸ÓAˆDô —j‘jÐ!>Ó?ˆGä Ÿh™h w°Ó5°aÑ8ˆOÜ"Ø'¸HÀjÐ;QôˆGð ŠNð (ô Ðó    Úservicer$   c                 ó  — | j                  «       j                  «       j                  d|d   ¬«      j                  «       }t	        |«      }d }|d   d   }|D ]  }|d   }|dk(  sŒ|d   }Œ |€t
        ‚|d	   }| j                  «       j                  «       j                  d|¬«      j                  «       }	|	d
   }
d }|
D ]'  }|d   d   }|D ]  }|d   dk(  sŒ|d   }||k(  sŒ|}Œ Œ) |€t
        ‚t	        |«      }t        ||g¬«      S )NÚmeÚid)ÚuserIdr+   r   r   r   zIn-Reply-Tor   ÚthreadIdÚmessagesz
Message-ID)r.   )Úusersr.   ÚgetÚexecuter&   r   Úthreadsr   )r(   r$   r	   Úmessage_contentÚin_reply_toÚ
email_datar    r   Ú	thread_idÚthreadr.   Úresponse_emailÚ
message_idÚstarter_contents                 r%   Ú_get_message_datar;   #   s4  € Ø
�-‰-‹/×
"Ñ
"Ó
$×
(Ñ
(°¸À¹Ð
(Ó
G×
OÑ
OÓ
Q€CÜ,¨SÓ1€OØ€KØ�Y‘ 	Ñ*€JÛˆØ�f‰~ˆØ�=Ó Ø  ™/‰Kð ð ÐÜÐà�J‘€Ià�]‰]‹_×$Ñ$Ó&×*Ñ*°$¸9Ð*ÓE×MÑMÓO€FØ�jÑ!€Hà€NÛˆØ˜YÑ'¨	Ñ2ˆ
Û ˆFØ�f‰~ Ó-Ø# G™_�
Ø Ó,Ø%,‘Nñ	 !ð ð ÐÜÐÜ,¨^Ó<€OÜ °/Ð BÔCÐCr'   z0.0.32z1.0z&langchain_google_community.GMailLoader)ÚsinceÚremovalÚalternative_importc            	       óH   ‡ — e Zd ZdZd	dedededdfˆ fd„Zdee	   fd„Z
ˆ xZS )
ÚGMailLoadera*  Load data from `GMail`.

    There are many ways you could want to load data from GMail.
    This loader is currently fairly opinionated in how to do so.
    The way it does it is it first looks for all messages that you have sent.
    It then looks for messages where you are responding to a previous email.
    It then fetches that previous email, and creates a training example
    of that email, followed by your email.

    Note that there are clear limitations here. For example,
    all examples created are only looking at the previous email for context.

    To use:

    - Set up a Google Developer Account:
        Go to the Google Developer Console, create a project,
        and enable the Gmail API for that project.
        This will give you a credentials.json file that you'll need later.
    ÚcredsÚnÚraise_errorr
   Nc                 óL   •— t         ‰| �  «        || _        || _        || _        y )N)ÚsuperÚ__init__rA   rB   rC   )ÚselfrA   rB   rC   Ú	__class__s       €r%   rF   zGMailLoader.__init__\   s$   ø€ Ü‰ÑÔØˆŒ
ØˆŒØ&ˆÕr'   c              #   ól  K  — ddl m}  |dd| j                  ¬«      }|j                  «       j	                  «       j                  ddg| j                  ¬«      j                  «       }|j                  d	g «      }|D ]  }	 t        ||«      –— Œ y # t        $ r}| j                  r|‚Y d }~Œ1d }~ww xY w­w)
Nr   )ÚbuildÚgmailÚv1)Úcredentialsr*   ÚSENT)r,   ÚlabelIdsÚ
maxResultsr.   )Úgoogleapiclient.discoveryrJ   rA   r/   r.   ÚlistrB   r1   r0   r;   Ú	ExceptionrC   )rG   rJ   r(   Úresultsr.   r$   Úes          r%   Ú	lazy_loadzGMailLoader.lazy_loadb   s�   è ø€ Ý3á˜ °4·:±:Ô>ˆà�M‰M‹Oß‰X‹Zß‰T˜¨¨¸T¿V¹VˆTÓDß‰W‹Yð	 	ð —;‘;˜z¨2Ó.ˆÛˆGðÜ'¨°Ó9Ó9ñ  øô ò à×#Ò#Ø�Gäûðüs0   ‚A<B4Á?BÂB4Â	B1ÂB,Â'B4Â,B1Â1B4)éd   F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚintÚboolrF   r   r   rV   Ú__classcell__)rH   s   @r%   r@   r@   B   s:   ø„ ññ('˜cð ' cð '¸dð 'Ètõ 'ð˜8 KÑ0÷ r'   r@   )r   r   Útypingr   r   Úlangchain_core._api.deprecationr   Úlangchain_core.chat_loadersr   Úlangchain_core.chat_sessionsr   Úlangchain_core.messagesr   r&   r;   r@   © r'   r%   Ú<module>re      st   ðÛ Û 	ß  å 6Ý 6Ý 4Ý 0ð ð ¨ó ð0D˜sð D¨Sð D°[ó Dñ> Ø
ØØ?ôô
.�.ó .óñ
.r'   