o
    Zhd                     @   sh   d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZ G dd deZG d	d
 d
eZdS )z%Tool for the SearchApi.io search API.    )Optional)AsyncCallbackManagerForToolRunCallbackManagerForToolRun)BaseTool)Field)SearchApiAPIWrapperc                   @   sn   e Zd ZU dZdZeed< dZeed< eed< 	dded	e	e
 d
efddZ	dded	e	e d
efddZdS )SearchAPIRunz.Tool that queries the SearchApi.io search API.Z	searchapinamezGoogle search API provided by SearchApi.io.This tool is handy when you need to answer questions about current events.Input should be a search query.descriptionapi_wrapperNqueryrun_managerreturnc                 C   s   | j |S zUse the tool.)r   runselfr   r    r   _/var/www/html/lang_env/lib/python3.10/site-packages/langchain_community/tools/searchapi/tool.py_run   s   zSearchAPIRun._runc                    s   | j |I dH S zUse the tool asynchronously.N)r   Zarunr   r   r   r   _arun"   s   zSearchAPIRun._arunN)__name__
__module____qualname____doc__r	   str__annotations__r
   r   r   r   r   r   r   r   r   r   r   r      s,   
 

r   c                   @   sx   e Zd ZU dZdZeed< dZeed< ee	dZ
e	ed< 	dd	ed
ee defddZ	dd	ed
ee defddZdS )SearchAPIResultsz?Tool that queries the SearchApi.io search API and returns JSON.Zsearchapi_results_jsonr	   zGoogle search API provided by SearchApi.io.This tool is handy when you need to answer questions about current events.The input should be a search query and the output is a JSON object with the query results.r
   )default_factoryr   Nr   r   r   c                 C   s   t | j|S r   )r   r   resultsr   r   r   r   r   7   s   zSearchAPIResults._runc                    s   | j |I dH  S r   )r   Zaresults__str__r   r   r   r   r   ?   s   zSearchAPIResults._arunr   )r   r   r   r   r	   r   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   +   s,   
 

r   N)r   typingr   Zlangchain_core.callbacksr   r   Zlangchain_core.toolsr   Zpydanticr   Z'langchain_community.utilities.searchapir   r   r   r   r   r   r   <module>   s    