a
    bgc                     @   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 Serper.dev Google Search API.    )Optional)AsyncCallbackManagerForToolRunCallbackManagerForToolRun)BaseTool)Field)GoogleSerperAPIWrapperc                   @   sb   e Zd ZU dZdZeed< dZeed< eed< dee	e
 edd	d
Zdee	e edddZdS )GoogleSerperRunz3Tool that queries the Serper.dev Google search API.Zgoogle_serpernamez~A low-cost Google Search API.Useful for when you need to answer questions about current events.Input should be a search query.descriptionapi_wrapperNqueryrun_managerreturnc                 C   s   t | j|S zUse the tool.)strr   runselfr   r    r   z/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain_community/tools/google_serper/tool.py_run   s    zGoogleSerperRun._runc                    s   | j |I dH  S zUse the tool asynchronously.N)r   Zarun__str__r   r   r   r   _arun"   s    zGoogleSerperRun._arun)N)N)__name__
__module____qualname____doc__r	   r   __annotations__r
   r   r   r   r   r   r   r   r   r   r   r      s"   

  r   c                   @   sl   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eee ed	d
dZdeee ed	ddZdS )GoogleSerperResultszITool that queries the Serper.dev Google Search API
    and get back json.Zgoogle_serper_results_jsonr	   zA low-cost Google Search API.Useful for when you need to answer questions about current events.Input should be a search query. Output is a JSON object of the query resultsr
   )default_factoryr   Nr   c                 C   s   t | j|S r   )r   r   resultsr   r   r   r   r   7   s    zGoogleSerperResults._runc                    s   | j |I dH  S r   )r   Zaresultsr   r   r   r   r   r   ?   s    zGoogleSerperResults._arun)N)N)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.google_serperr   r   r    r   r   r   r   <module>   s   