
    h                     l    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e      Z G d de
      Zy	)
    )DictOptionalType)CallbackManagerForToolRun)	BaseModelField)GmailBaseToolc                   0    e Zd ZU dZ edd      Zeed<   y)GetThreadSchemazInput for GetMessageTool..zThe thread ID.)description	thread_idN)__name__
__module____qualname____doc__r   r   str__annotations__     h/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/langchain_community/tools/gmail/get_thread.pyr   r   	   s    # $Is r   r   c                   `    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Zy)GmailGetThreadz)Tool that gets a thread by ID from Gmail.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           	      X   | j                   j                         j                         j                  d|      }|j	                         }t        |t              st        d      |d   }g |d<   g d}|D ]-  }|d   j                  |D ci c]  }||v s|||    c}       / |S c c}w )zRun the tool.me)userIdidz'The output of the query must be a list.messages)r!   snippetr#   )	api_resourceusersthreadsgetexecute
isinstancedict
ValueErrorappend)	selfr   r   querythread_datar"   keys_to_keepmessageks	            r   _runzGmailGetThread._run   s     !!'')11377t	7Rmmo+t,FGGz*"$J3 	G
#**(4E1WGAJE	  Fs   
	B'
B'
)N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r3   r   r   r   r   r      s^    3"D#"	2  
 *9Ko&8
 <@ 78 
	r   r   N)typingr   r   r   langchain_core.callbacksr   pydanticr   r   $langchain_community.tools.gmail.baser	   r   r   r   r   r   <module>r8      s,    ' ' > % >i ] r   