a
    bg
                     @   s   d Z ddlmZmZ ddlmZmZ ddlmZ ddl	m
Z
mZmZ ddlmZ G dd de
ZG d	d
 d
eZG dd deZdS )z Tool for the SearxNG search API.    )OptionalType)AsyncCallbackManagerForToolRunCallbackManagerForToolRun)BaseTool)	BaseModel
ConfigDictField)SearxSearchWrapperc                   @   s$   e Zd ZU dZeddZeed< dS )SearxSearchQueryInputzInput for the SearxSearch tool.zquery to look up on searx)descriptionqueryN)__name__
__module____qualname____doc__r	   r   str__annotations__ r   r   y/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain_community/tools/searx_search/tool.pyr      s   
r   c                   @   s   e Zd ZU dZdZeed< dZeed< eed< e	e
dZe
ed< eZee ed	< deee edddZdeee edddZd
S )SearxSearchRunz#Tool that queries a Searx instance.Zsearx_searchnamezvA meta search engine.Useful for when you need to answer questions about current events.Input should be a search query.r   wrapperdefault_factorykwargsargs_schemaNr   run_managerreturnc                 C   s   | j j|fi | jS zUse the tool.)r   runr   selfr   r   r   r   r   _run"   s    zSearxSearchRun._runc                    s   | j j|fi | jI dH S zUse the tool asynchronously.N)r   Zarunr   r"   r   r   r   _arun*   s    zSearxSearchRun._arun)N)N)r   r   r   r   r   r   r   r   r
   r	   dictr   r   r   r   r   r   r   r$   r   r&   r   r   r   r   r      s&   

  r   c                   @   s   e Zd ZU dZdZeed< dZeed< eed< dZ	e
ed< eed	Zeed
< eZee ed< eddZdeee edddZdeee edddZdS )SearxSearchResultsz6Tool that queries a Searx instance and gets back json.Zsearx_search_resultsr   zA meta search engine.Useful for when you need to answer questions about current events.Input should be a search query. Output is a JSON array of the query resultsr   r      num_resultsr   r   r   Zallow)extraNr   c                 C   s   t | jj|| jfi | jS r    )r   r   resultsr*   r   r"   r   r   r   r$   E   s    zSearxSearchResults._runc                    s$   | j j|| jfi | jI dH  S r%   )r   Zaresultsr*   r   __str__r"   r   r   r   r&   M   s    zSearxSearchResults._arun)N)N)r   r   r   r   r   r   r   r   r
   r*   intr	   r'   r   r   r   r   r   r   Zmodel_configr   r   r$   r   r&   r   r   r   r   r(   3   s.   

  r(   N)r   typingr   r   Zlangchain_core.callbacksr   r   Zlangchain_core.toolsr   Zpydanticr   r   r	   Z*langchain_community.utilities.searx_searchr
   r   r   r(   r   r   r   r   <module>   s   