
    j              	           U d dl Z d dlZd dlmZmZmZmZ d dlmZ d dl	m
Z
 ddl erd dlmZ d dl	mZmZ d	ed
ddddee   fdZdee
ed   f   fdZdaeee
ed   f      ed<   d Zde
ded   fdZy)    N)TYPE_CHECKINGDictOptionalType)verbose_logger)	CallTypes   )*)BaseTranslation)	ModelInfoUsagecustom_llm_providerusager   
model_infor   returnc                     | dk(  rddl m}  |||      S | dk(  rddlm}  |||      S | j	                  d      rddlm}  |||      S | d	k(  ry
| dk(  rddlm}  |||      S y)z
    Get the cost for a web search request for a given model.

    Args:
        custom_llm_provider: The custom LLM provider.
        usage: The usage object.
        model_info: The model info.
    geminir	   )cost_per_web_search_request)r   r   	anthropic)!get_cost_for_anthropic_web_search)r   r   	vertex_ai
perplexityg        xaiN)gemini.cost_calculatorr   anthropic.cost_calculationr   
startswith vertex_ai.gemini.cost_calculatorxai.cost_calculator)r   r   r   r   r   %cost_per_web_search_request_vertex_ais         n/Users/manta/Documents/Projects/TheRoad-I1/backend/.venv/lib/python3.12/site-packages/litellm/llms/__init__.pyget_cost_for_web_search_requestr!      s~     h&G*:NN		+Q0JeTT		'	'	4	
 55ZXX		, 		%D*:NN    r   c            
      6   i } 	 t         j                  j                  t              }|}t         j                  j	                  |      st        j                  d       | S t        j                  |      D ]S  \  }}}|D cg c]  }|j                  d      r|dk7  s| c}|dd t         j                  j                  |      dk(  sVd|v s[t         j                  j                  |t         j                  j                  |            }d|j                  t         j                  d      z   }	 t        j                  d	|        t        j                  |      }	t        |	d
      r_t!        |	d
      }
t#        |
t$              rC| j'                  |
       t        j                  d| dt)        |
j+                                       V t        j                  dt3        |        dt)        | j+                                       | S c c}w # t,        $ r&}t        j.                  d| d|        Y d}~d}~wt0        $ r&}t        j.                  d| d|        Y d}~d}~ww xY w# t0        $ r#}t        j.                  d|        Y d}~| S d}~ww xY w)a;  
    Discover guardrail translation mappings by scanning the llms directory structure.

    Scans for modules with guardrail_translation_mappings dictionaries and aggregates them.

    Returns:
        Dict[CallTypes, Type[BaseTranslation]]: A dictionary mapping call types to their translation handler classes
    zllms directory not found__base_llmNguardrail_translationz__init__.pyzlitellm..z'Discovering guardrail translations in: guardrail_translation_mappingsz(Found guardrail_translation_mappings in z: zCould not import zError processing zDiscovered z! guardrail translation mappings: z2Error discovering guardrail translation mappings: )ospathdirname__file__existsr   debugwalkr   basenamerelpathreplacesep	importlibimport_modulehasattrgetattr
isinstancedictupdatelistkeysImportErrorerror	Exceptionlen)discovered_mappingscurrent_dirllms_dirrootdirsfilesdrel_pathmodule_pathmodulemappingses               r    'discover_guardrail_translation_mappingsrM   5   s[    EG4Wggooh/ww~~h'  !;<&& "$!2D$"&U$Qall4.@Q*_q$UDG   &*AA!U* 77??41JK(8+;+;BFFC+HH"((A+O '44[AF v'GH#*63S#T%h5/66x@*00"J;-WYZ^_g_l_l_nZoYp q5 "3J 	#1233TUYZmZrZrZtUuTvw	
 U V8 # "((+<[MA3)OP  "((+<[MA3)OP  WQRSQTUVVWs   AI, !I,  HHH!(I, 
I, A I, 0BH>I, I, 	I)H71I, 7I)I$I, $I))I, ,	J5JJ'endpoint_guardrail_translation_mappingsc                  .    t         
t               a t         S )N)rN   rM    r"   r    #load_guardrail_translation_mappingsrQ      s    .635 	0 32r"   	call_typec           	          t         
t               a | t         vr,t        d|  dt        t         j	                                      t         |    S )aO  
    Get the guardrail translation handler for a given call type.

    Args:
        call_type: The type of call (e.g., completion, acompletion, anthropic_messages)

    Returns:
        The translation handler class for the given call type

    Raises:
        ValueError: If no translation mapping exists for the given call type
    z6No guardrail translation mapping found for call_type: z. Available mappings: )rN   rM   
ValueErrorr;   r<   )rR   s    r    !get_guardrail_translation_mappingrU      sb      /635 	0
 ??DYK P##'(O(T(T(V#W"XZ
 	
 39==r"   )r4   r)   typingr   r   r   r   litellm._loggingr   litellm.types.utilsr    <litellm.llms.base_llm.guardrail_translation.base_translationr   r   r   strfloatr!   rM   rN   __annotations__rQ   rU   rP   r"   r    <module>r^      s     	 6 6 + )  5!!%,!:E!e_!HCD*+	+,CR 	 (D*+	+,* 	
3> >tDU?V >r"   