
    iq                         d Z ddlmZmZmZmZmZmZmZ ddl	Z	ddl
mZ ddlmZ ddlmZ erddlmZ neZ G d d	e      Z G d
 de      Z G d d      Zy)z+
Base Search transformation configuration.
    )TYPE_CHECKINGAnyDictListLiteralOptionalUnionN)PrivateAttrBaseLLMException)LiteLLMPydanticObjectBase)Loggingc                   `    e Zd ZU dZeed<   eed<   eed<   dZee   ed<   dZee   ed<   dd	iZ	y)
SearchResultzSingle search result.titleurlsnippetNdatelast_updatedextraallow)
__name__
__module____qualname____doc__str__annotations__r   r   r   model_config     |/Users/manta/Documents/Projects/TheRoad-I1/.venv/lib/python3.12/site-packages/litellm/llms/base_llm/search/transformation.pyr   r      s:    J	HLD(3-"&L(3-&W%Lr    r   c                   T    e Zd ZU dZee   ed<   dZeed<   ddiZ	 e
e      Zeed<   y	)
SearchResponsez
    Standard Search response format.
    Standardized to Perplexity Search format - other providers should transform to this format.
    resultssearchobjectr   r   )default_factory_hidden_paramsN)r   r   r   r   r   r   r   r&   r   r   r
   dictr(   r   r    r!   r#   r#      s9    
 ,FCW%L 't<ND<r    r#   c                   ,   e Zd ZdZddZedefd       Zded   fdZ	ede
fd       Z	 	 dd	ed
ee   dee   defdZ	 ddee   dedeeeee   f      defdZdeeee   f   dedeeee   f   fdZdej*                  dedefdZdeded	edefdZy)BaseSearchConfigzi
    Base configuration for Search transformations.
    Handles provider-agnostic Search operations.
    returnNc                      y Nr   selfs    r!   __init__zBaseSearchConfig.__init__3   s    r    c                       y)zr
        UI-friendly name for the search provider.
        Override in provider-specific implementations.
        zUnknown Search Providerr   r   r    r!   ui_friendly_namez!BaseSearchConfig.ui_friendly_name6   s     )r    )GETPOSTc                      y)z
        Get HTTP method for search requests.
        Override in provider-specific implementations if needed.

        Returns:
            HTTP method ('GET' or 'POST'). Default is 'POST'.
        r5   r   r/   s    r!   get_http_methodz BaseSearchConfig.get_http_method>   s     r    c                  
    h dS )z
        Get the set of Perplexity unified search parameters.
        These are the standard parameters that providers should transform from.

        Returns:
            Set of parameter names that are part of the unified spec
        >   countrymax_resultsmax_tokens_per_pagesearch_domain_filterr   r   r    r!   (get_supported_perplexity_optional_paramsz9BaseSearchConfig.get_supported_perplexity_optional_paramsH   s    
 	
r    headersapi_keyapi_basec                     |S )zq
        Validate environment and return headers.
        Override in provider-specific implementations.
        r   )r0   r>   r?   r@   kwargss        r!   validate_environmentz%BaseSearchConfig.validate_environmentX   s	     r    optional_paramsdatac                     t        d      )a  
        Get complete URL for Search endpoint.

        Args:
            api_base: Base URL for the API
            optional_params: Optional parameters for the request
            data: Transformed request body from transform_search_request().
                  Some providers (e.g., Google PSE) use GET requests and need
                  the request body to construct query parameters in the URL.
                  Can be a dict or list of dicts depending on provider.
            **kwargs: Additional keyword arguments

        Returns:
            Complete URL for the search endpoint

        Note:
            Override in provider-specific implementations.
        z0get_complete_url must be implemented by providerNotImplementedError)r0   r@   rD   rE   rB   s        r!   get_complete_urlz!BaseSearchConfig.get_complete_urle   s    2 ""TUUr    queryc                     t        d      )a?  
        Transform Search request to provider-specific format.
        Override in provider-specific implementations.

        Args:
            query: Search query (string or list of strings)
            optional_params: Optional parameters for the request

        Returns:
            Dict with request data
        z8transform_search_request must be implemented by providerrG   )r0   rJ   rD   rB   s       r!   transform_search_requestz)BaseSearchConfig.transform_search_request   s    " "F
 	
r    raw_responselogging_objc                     t        d      )z
        Transform provider-specific Search response to standard format.
        Override in provider-specific implementations.
        z9transform_search_response must be implemented by providerrG   )r0   rM   rN   rB   s       r!   transform_search_responsez*BaseSearchConfig.transform_search_response   s     "G
 	
r    error_messagestatus_codec                     t        |||      S )z-Get appropriate error class for the provider.)rR   messager>   r   )r0   rQ   rR   r>   s       r!   get_error_classz BaseSearchConfig.get_error_class   s      #!
 	
r    )r,   N)NNr.   )r   r   r   r   r1   staticmethodr   r3   r   r7   setr=   r   r   rC   r)   r	   r   rI   rL   httpxResponseLiteLLMLoggingObjr#   rP   int	ExceptionrU   r   r    r!   r+   r+   -   sf   
 )c ) )!7  
c 
 
$ "&"&	 # 3-	 
" 37	V3-V V uT4:-./	V 
V6
S$s)^$
 

 
tT$Z	 
*
nn
 '

 



 
 	

 

r    r+   )r   typingr   r   r   r   r   r   r	   rX   pydanticr
   )litellm.llms.base_llm.chat.transformationr   litellm.types.llms.baser   *litellm.litellm_core_utils.litellm_loggingr   rZ   r   r#   r+   r   r    r!   <module>rb      sT    L K K    F =W	&, 	&=. =A
 A
r    