o
    ưi                     @   sZ   d Z ddlmZmZ ddlmZ 			ddedee ded	ee d
ee	e	f f
ddZ
dS )z(
Cost calculation for search providers.
    )OptionalTuple)get_model_infoN   modelcustom_llm_providernumber_of_queriesoptional_paramsreturnc                 C   s   t | |d}|d}|r@t|tr@|pi dd}d}|D ]}|d \}	}
|	|  kr0|
kr8n q|d } nq|d d }n	t|dpGd}|| }|dfS )	a`  
    Calculate cost for search-only providers.
    
    Returns (input_cost, output_cost) where input_cost = queries * cost_per_query
    Supports tiered pricing based on max_results parameter.
    
    Args:
        model: Model name (e.g., "exa_ai/search", "tavily/search")
        custom_llm_provider: Provider name (e.g., "exa_ai", "tavily")
        number_of_queries: Number of search queries performed (default: 1)
        optional_params: Optional parameters including max_results for tiered pricing
        
    Returns:
        Tuple of (input_cost, output_cost) where output_cost is always 0.0
    )r   r   tiered_pricingmax_results
   g        Zmax_results_rangeZinput_cost_per_query)r   get
isinstancelistfloat)r   r   r   r	   Z
model_infor   r   Zcost_per_queryZtierZ	range_minZ	range_maxZ
total_cost r   U/home/app/Keep/.python/lib/python3.10/site-packages/litellm/search/cost_calculator.pysearch_provider_cost_per_query	   s    
r   )Nr   N)__doc__typingr   r   Zlitellm.utilsr   strintdictr   r   r   r   r   r   <module>   s"    
