o
    Zh                     @   s`   d dl mZmZmZ d dlmZ d dlmZmZ d dl	m
Z
 G dd deZG dd de
Zd	S )
    )DictOptionalType)CallbackManagerForToolRun)	BaseModelField)GmailBaseToolc                   @   s&   e Zd ZU dZedddZeed< dS )GetThreadSchemazInput for GetMessageTool..zThe thread ID.)description	thread_idN)__name__
__module____qualname____doc__r   r   str__annotations__ r   r   b/var/www/html/lang_env/lib/python3.10/site-packages/langchain_google_community/gmail/get_thread.pyr	   	   s   
 r	   c                   @   sX   e Zd ZU dZdZeed< dZeed< eZ	e
e ed< 	dded	ee d
efddZdS )GmailGetThreadz)Tool that gets a thread by ID from Gmail.Zget_gmail_threadnamezyUse this tool to search for email messages. The input must be a valid Gmail query. The output is a JSON list of messages.r
   args_schemaNr   run_managerreturnc                    st   | j   jd|d}| }t|tstd|d }g |d< g d}|D ] |d  fdd|D  q'|S )zRun the tool.me)ZuserIdidz'The output of the query must be a list.messages)r   snippetr   c                    s   i | ]}| v r| | qS r   r   ).0kmessager   r   
<dictcomp>.   s    z'GmailGetThread._run.<locals>.<dictcomp>)	Zapi_resourceZusersthreadsgetexecute
isinstancedict
ValueErrorappend)selfr   r   queryZthread_datar   Zkeys_to_keepr   r   r   _run   s   
zGmailGetThread._run)N)r   r   r   r   r   r   r   r
   r	   r   r   r   r   r   r+   r   r   r   r   r      s   
 
r   N)typingr   r   r   Zlangchain_core.callbacksr   Zpydanticr   r   Z%langchain_google_community.gmail.baser   r	   r   r   r   r   r   <module>   s    
