o
    i	                  
   @   s   d dl mZ d dlmZ d dlmZ d dlmZmZ d dl	m
Z
 zd dlmZ W n ey9 Z zededZ[ww d	ZG d
d deZeee ZeG dd dZdefddZdS )    )	dataclass)Literal)TypeAdapter)Any	TypedDict)Tool)AsyncTavilyClientu   Please install `tavily-python` to use the Tavily search tool, you can use the `tavily` optional group — `pip install "pydantic-ai-slim[tavily]"`N)tavily_search_toolc                   @   s8   e Zd ZU dZeed< 	 eed< 	 eed< 	 eed< dS )TavilySearchResultzA Tavily search result.

    See [Tavily Search Endpoint documentation](https://docs.tavily.com/api-reference/endpoint/search)
    for more information.
    titleurlcontentscoreN)__name__
__module____qualname____doc__str__annotations__float r   r   e/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/pydantic_ai/common_tools/tavily.pyr
      s   
 r
   c                
   @   sN   e Zd ZU dZeed< 	 			ddeded d	ed
 ded dB fddZdS )TavilySearchToolzThe Tavily search tool.clientbasicgeneralNquerysearch_deep)r   advancedtopic)r   news
time_range)dayweekmonthyeardwmyc                    s*   | j j||||dI dH }t|d S )ax  Searches Tavily for the given query and returns the results.

        Args:
            query: The search query to execute with Tavily.
            search_deep: The depth of the search.
            topic: The category of the search.
            time_range: The time range back from the current date to filter results.

        Returns:
            The search results.
        )search_depthr   r!   Nresults)r   searchtavily_search_tavalidate_python)selfr   r   r   r!   r+   r   r   r   __call__/   s   zTavilySearchTool.__call__)r   r   N)	r   r   r   r   r   r   r   r   r0   r   r   r   r   r   (   s    
 
r   api_keyc                 C   s   t t tt| djdddS )zCreates a Tavily search tool.

    Args:
        api_key: The Tavily API key.

            You can get one by signing up at [https://app.tavily.com/home](https://app.tavily.com/home).
    )r   tavily_searchz<Searches Tavily for the given query and returns the results.)namedescription)r   r   r   r   r0   )r1   r   r   r   r	   E   s
   r	   )dataclassesr   typingr   pydanticr   typing_extensionsr   r   pydantic_ai.toolsr   tavilyr   ImportError_import_error__all__r
   listr-   r   r   r	   r   r   r   r   <module>   s*    