
    i                     ^    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
Z
y)z(
Cost calculation for search providers.
    )OptionalTuple)get_model_infoNmodelcustom_llm_providernumber_of_queriesoptional_paramsreturnc                 :   t        | |      }|j                  d      }|rUt        |t              rE|xs i j                  dd      }d}|D ]  }|d   \  }	}
|	|cxk  r|
k  sn |d   } n( |d   d   }nt	        |j                  d      xs d      }||z  }|dfS )	aP  
    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        max_results_rangeinput_cost_per_query)r   get
isinstancelistfloat)r   r   r   r	   
model_infor   r   cost_per_querytier	range_min	range_max
total_costs               o/Users/manta/Documents/Projects/TheRoad-I1/.venv/lib/python3.12/site-packages/litellm/search/cost_calculator.pysearch_provider_cost_per_queryr   	   s    *  eATUJ  ^^$45N*^T:&,"112
 "D#'(;#< IyK494!%&<!=	 # ,B/0FGN z~~.DELM"^3J    )N   N)__doc__typingr   r   litellm.utilsr   strintdictr   r    r   r   <module>r'      sa    # (
 *.&*	,,!#, , d^	,
 5%<,r   