
    Ng
                         d Z ddlmZmZmZ ddl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dS )z
Tool for the AskNews API.

To use this tool, you must first set your credentials as environment variables:
    ASKNEWS_CLIENT_ID
    ASKNEWS_CLIENT_SECRET
    )AnyOptionalType)AsyncCallbackManagerForToolRunCallbackManagerForToolRun)BaseTool)	BaseModelField)AskNewsAPIWrapperc                   f    e Zd ZU dZ ed          Zeed<    edd          Ze	e
         ed<   dS )	SearchInputz"Input for the AskNews Search tool.zMSearch query to be used for finding real-time or historical news information.)descriptionqueryr   a  If the Assistant deems that the event may have occurred more than 48 hours ago, it estimates the number of hours back to search. For example, if the event was one month ago, the Assistant may set this to 720. One week would be 168. The Assistant can estimate up to on year back (8760).
hours_backN)__name__
__module____qualname____doc__r
   r   str__annotations__r   r   int     b/var/www/html/ai-engine/env/lib/python3.11/site-packages/langchain_community/tools/asknews/tool.pyr   r      s~         ,,  E3    !&	W! ! !J     r   r   c                       e Zd ZU dZdZeed<   dZeed<    ee	          Z
e	ed<   dZeed	<   eZeee                  ed
<   	 	 ddededee         dedef
dZ	 	 ddededee         dedef
dZdS )AskNewsSearchz#Tool that searches the AskNews API.asknews_searchnamezThis tool allows you to perform a search on up-to-date news and historical news. If you needs news from more than 48 hours ago, you can estimate the number of hours back to search.r   )default_factoryapi_wrapper
   max_resultsargs_schemar   Nr   r   run_managerkwargsreturnc                     	 | j                             ||| j                  S # t          $ r}t	          |          cY d}~S d}~ww xY w)zUse the tool.r   r"   N)r    search_newsr"   	Exceptionreprselfr   r   r$   r%   es         r   _runzAskNewsSearch._run2   si    	#//% , 0   
  	 	 	77NNNNNN	s   !$ 
AAAAc                    K   	 | j                             ||| j                   d{V S # t          $ r}t	          |          cY d}~S d}~ww xY w)zUse the tool asynchronously.r(   N)r    asearch_newsr"   r*   r+   r,   s         r   _arunzAskNewsSearch._arunC   s      	)66% , 7         
  	 	 	77NNNNNN	s   ', 
AA
A
A)r   N)r   r   r   r   r   r   r   r   r
   r   r    r"   r   r   r#   r   r   r	   r   r   r/   r   r2   r   r   r   r   r   %   s?        -- D#   	*    
 &+U;L%M%M%MK"MMMK-8K$y/*888
 ;?	   78	
  
   ( @D	   <=	
  
     r   r   N)r   typingr   r   r   langchain_core.callbacksr   r   langchain_core.toolsr   pydanticr	   r
   %langchain_community.utilities.asknewsr   r   r   r   r   r   <module>r8      s     ' & & & & & & & & &        * ) ) ) ) ) % % % % % % % % C C C C C C    )    - - - - -H - - - - -r   