Ë
    uPêj²   ã            	       ó   — U d dl Z d dlZd dl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dz  fd„Zd	ed
ddddedz  fd„Zdeeed   f   fd„Zdaeeed   f   dz  ed<   d„ Zdeded   fd„Zy)é    N)ÚTYPE_CHECKINGÚFinal)Úverbose_logger)Ú	CallTypesé   )Ú*)ÚBaseTranslation)Ú	ModelInfoÚUsageÚcustom_llm_providerÚusager   Ú
model_infor
   Úreturnc                 óP   — | dk7  r| j                  d«      syddlm}  |||¬«      S )zÑ
    Get the cost of Grounding with Google Maps for a given model. Only Gemini models on the
    Gemini API and Vertex AI can populate the Maps grounding counter, so every other provider
    returns None.
    ÚgeminiÚ	vertex_aiNr   )Ú&cost_per_google_maps_grounding_request©r   r   )Ú
startswithÚgemini.cost_calculatorr   )r   r   r   r   s       úZ/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/llms/__init__.pyÚ*get_cost_for_google_maps_grounding_requestr      s-   € ð ˜hÒ&Ð/B×/MÑ/MÈkÔ/ZØÝNá1¸È*ÔUÐUó    c                 ó”  — | dk(  rddl m}  |||¬«      S | dk(  rddlm}  |||¬«      S | j	                  d«      r]|r|j                  d	d
«      nd
}d|j                  «       v r%ddlm} t        j                  d«        |||¬«      S ddl	m}  |||¬«      S | dk(  ry| dk(  rddl
m}  |||¬«      S | 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.
    r   r   )Úcost_per_web_search_requestr   Ú	anthropic)Ú!get_cost_for_anthropic_web_search)r   r   r   ÚkeyÚ ÚclaudeuS   vertex_ai/claude model detected â€” routing web search cost to Anthropic calculatorÚ
perplexityg        ÚxaiÚgroqN)r   r   Úanthropic.cost_calculationr   r   ÚgetÚlowerr   ÚdebugÚ vertex_ai.gemini.cost_calculatorÚxai.cost_calculatorÚgroq.cost_calculator)r   r   r   r   r   Ú	model_keyÚ%cost_per_web_search_request_vertex_aiÚ groq_cost_per_web_search_requests           r   Úget_cost_for_web_search_requestr.       sà   € ð ˜hÒ&ÝGá*°À:ÔNÐNØ	 Ò	+ÝQá0¸JÈeÔTÐTØ	×	'Ñ	'¨Ô	4ñ >H 
§¡¨u°bÔ 9ÈRˆ	Ø�y—‘Ó(Ñ(ÝUä× Ñ Ð!vÔwÙ4À
ÐRWÔXÐXõ	
ñ 5¸5ÈZÔXÐXØ	 Ò	,ð Ø	 Ò	%ÝDá*°À:ÔNÐNØ	 Ò	&õ	
ñ 0°eÈ
ÔSÐSàr   r	   c            	      óà  — i } 	 t         j                  j                  t        «      }|}t         j                  j	                  |«      st        j                  d«       | S t        j                  |«      D �]M  \  }}}|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$        «      r?| j'                  |
«       t        j                  d|t)        |
j+                  «       «      «       �ŒP 	 ddlm} | j'                  |«       t        j                  dt)        |j+                  «       «      «       t        j                  dt7        | «      t)        | j+                  «       «      «       | S c c}w # t,        $ r"}t        j.                  d||«       Y d}~�Œúd}~wt0        $ r"}t        j.                  d||«       Y d}~�Œ#d}~ww xY w# t,        $ r t        j                  d«       Y Œµ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: %sÚguardrail_translation_mappingsz.Found guardrail_translation_mappings in %s: %szCould not import %s: %szError processing %s: %sr   )r4   z-Loaded MCP guardrail translation mappings: %sz:MCP guardrail translation mappings not available; skippingz0Discovered %s guardrail translation mappings: %sz4Error discovering guardrail translation mappings: %s)ÚosÚpathÚdirnameÚ__file__Úexistsr   r'   Úwalkr   ÚbasenameÚrelpathÚreplaceÚsepÚ	importlibÚimport_moduleÚhasattrÚgetattrÚ
isinstanceÚdictÚupdateÚlistÚkeysÚImportErrorÚerrorÚ	ExceptionÚ<litellm.proxy._experimental.mcp_server.guardrail_translationr4   Úlen)Údiscovered_mappingsÚcurrent_dirÚllms_dirÚrootÚdirsÚfilesÚdÚrel_pathÚmodule_pathÚmoduleÚmappingsÚeÚ"mcp_guardrail_translation_mappingss                r   Ú'discover_guardrail_translation_mappingsrZ   S   s‡  € ð JLÐð>XäŸW™WŸ_™_¬XÓ6ˆØ%ˆä�w‰w�~‰~˜hÔ'Ü× Ñ Ð!;Ô<Ø&Ð&ô "$§¡¨Ó!2ó 	ÑˆD�$˜à"&ÖU˜Q¨a¯l©l¸4Õ.@ÀQÈ*Ã_’qÒUˆD‘ˆGô �w‰w×Ñ Ó%Ð)@Ó@À]ÐV[ÒE[äŸ7™7Ÿ?™?¨4´·±·±ÀÓ1JÓK�Ø(¨8×+;Ñ+;¼B¿F¹FÀCÓ+HÑH�ðä"×(Ñ(Ð)TÐVaÔbä&×4Ñ4°[ÓA�Fô ˜vÐ'GÔHÜ#*¨6Ð3SÓ#T˜Ü% h´Ô5Ø/×6Ñ6°xÔ@Ü*×0Ñ0Ø PÐR]Ô_cÐdl×dqÑdqÓdsÓ_tôùð+	ð@	_õð  ×&Ñ&Ð'IÔJÜ× Ñ Ø?ÜÐ7×<Ñ<Ó>Ó?ôô 	×ÑØ>ÜÐ#Ó$ÜÐ$×)Ñ)Ó+Ó,ô	
ð Ðùòi Vøô. #ò Ü"×(Ñ(Ð)BÀKÐQRÔSÝûÜ ò Ü"×(Ñ(Ð)BÀKÐQRÔSÝûðûô ò 	_Ü× Ñ Ð!]Ö^ð	_ûô ò XÜ×ÑÐSÐUV×WÐWàÐûðXús«   „AK Á!K Â IÂIÂIÂ!(K Ã
K ÃA K Ä0BIÇK ÇAJ È
7K ÉK É	JÉI.É(K É.JÉ:JÊK ÊJÊK ÊK Ê=K Ê?K Ë K Ë	K-ËK(Ë(K-Ú'endpoint_guardrail_translation_mappingsc                  ó.   — t         €
t        «       a t         S )N)r[   rZ   © r   r   Ú#load_guardrail_translation_mappingsr^   ¥   s   € ä.Ð6Ü2YÓ2[Ð/Ü2Ð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: )r[   rZ   Ú
ValueErrorrF   rG   )r_   s    r   Ú!get_guardrail_translation_mappingrb   ¬   s`   € ô  /Ð6Ü2YÓ2[Ð/ð Ô?Ñ?ÜØDÀYÀKð P#Ü#'Ô(O×(TÑ(TÓ(VÓ#WÐ"XðZó
ð 	
ô 3°9Ñ=Ð=r   )r?   r5   Útypingr   r   Úlitellm._loggingr   Úlitellm.types.utilsr   r   Ú<litellm.llms.base_llm.guardrail_translation.base_translationr	   r
   r   ÚstrÚfloatr   r.   rD   ÚtyperZ   r[   Ú__annotations__r^   rb   r]   r   r   ú<module>rk      sÞ   ðÜ Û 	ß 'å +Ý )ä áõ÷ 5ðVØðVØ%,ðVØ:EðVà
ˆT�\óVð0¸ð 0ÀWð 0ÐZeð 0ÐjoÐrvÑjvó 0ðfK°°iÀÐFWÑAXÐ6XÑ1Yó Kð^ \`Ð '¨¨i¸Ð>OÑ9PÐ.PÑ)QÐTXÑ)XÓ _ò3ð>°ð >¸tÐDUÑ?Vô >r   