Ë
    uPêj  ã                   ój   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 dedd	fd
„Z G d„ de«      Zy	)z[
Azure Anthropic transformation config - extends AnthropicConfig with Azure authentication
é    )ÚFinal)ÚAnthropicConfig)ÚBaseAzureLLM)ÚAllMessageValues)ÚGenericLiteLLMParamsÚoptional_paramsÚreturnNc                 óÄ   — | j                  d«      }t        |t        «      r|sy|j                  «       D ]  \  }}| j	                  ||«       Œ | j                  dd«       y)u¹  Promote anthropic-native passthrough keys out of ``extra_body``.

    ``azure_ai`` is an OpenAI-compatible provider, so non-OpenAI kwargs like
    ``output_config`` get auto-routed into ``extra_body`` by
    ``add_provider_specific_params_to_optional_params``. For the Azureâ†’Anthropic
    route those keys must reach the request body and be validated, so promote
    them. ``setdefault`` keeps explicit top-level values authoritative.
    Ú
extra_bodyN)ÚgetÚ
isinstanceÚdictÚitemsÚ
setdefaultÚpop)r   r   ÚkÚvs       ús/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/llms/azure_ai/anthropic/transformation.pyÚ&_promote_extra_body_to_optional_paramsr      s_   € ð (×+Ñ+¨LÓ9€JÜ�j¤$Ô'©zØØ× Ñ Ó"ò )‰ˆˆ1Ø×"Ñ" 1 aÕ(ð)à×Ñ˜ dÕ+ó    c                   ó°   ‡ — e Zd ZdZededz  fd„«       Zdefd„Z	 	 dde	dede
e   d	e	d
e	ez  dedz  dedz  de	fd„Zdede
e   d	e	d
e	de	de	fˆ fd„Zˆ xZS )ÚAzureAnthropicConfigz¾
    Azure Anthropic configuration that extends AnthropicConfig.
    The only difference is authentication - Azure uses api-key header or Azure AD token
    instead of x-api-key header.
    r	   Nc                  ó   — y)NÚazure_ai© ©Úselfs    r   Úcustom_llm_providerz(AzureAnthropicConfig.custom_llm_provider%   s   € àr   c                  ó   — y)NTr   r   s    r   Úshould_strip_billing_metadataz2AzureAnthropicConfig.should_strip_billing_metadata)   s   € Ør   ÚheadersÚmodelÚmessagesr   Úlitellm_paramsÚapi_keyÚapi_basec                 ó’  — t        |«       t        |t        «      r|rd|vri |¥d|i¥}t        di |¤Ž}n#|xs
 t        «       }|r|j                  s||_        t        j                  ||¬«      }|j                  d«      }	| j                  |¬«      }
| j                  |	¬«      }| j                  |j                  d«      ¬«      }| j                  |¬«      }| j                  |¬«      }| j                  |j                  d«      ¬	«      }| j                  ||
||xs d
||j                  dd«      ||¬«      }i |¥|¥}d|vrd|d<   |S )zÔ
        Validate environment and set up Azure authentication headers.
        Azure supports:
        1. API key via 'api-key' header
        2. Azure AD token via 'Authorization: Bearer <token>' header
        r%   )r!   r$   Útools)r#   )r(   Úmcp_servers)r)   zanthropic-beta)Úanthropic_beta_headerÚ Úis_vertex_requestF)Úcomputer_tool_usedÚprompt_caching_setÚpdf_usedr%   Úfile_id_usedr,   Úuser_anthropic_beta_headersÚmcp_server_usedzanthropic-versionz
2023-06-01r   )r   r   r   r   r%   r   Ú _base_validate_azure_environmentr   Úis_cache_control_setÚis_computer_tool_usedÚis_mcp_server_usedÚis_pdf_usedÚis_file_id_usedÚ _get_user_anthropic_beta_headersÚget_anthropic_headers)r   r!   r"   r#   r   r$   r%   r&   Úlitellm_params_objr(   r.   r-   r2   r/   r0   r1   Úanthropic_headerss                    r   Úvalidate_environmentz)AzureAnthropicConfig.validate_environment,   s‹  € ô  	/¨Ô?ô �n¤dÔ+á˜9¨NÑ:Ø!G NÐ!G°I¸wÑ!G�Ü!5Ñ!G¸Ñ!GÑà!/Ò!IÔ3GÓ3IÐáÐ1×9Ò9Ø-4Ð"Ô*ô ×?Ñ?ÈÐ`rÔsˆð '×*Ñ*¨7Ó3ˆØ$(×$=Ñ$=ÀxÐ$=Ó$PÐØ$(×$>Ñ$>ÀUÐ$>Ó$KÐØ!%×!8Ñ!8À_×EXÑEXÐYfÓEgÐ!8Ó!hˆØ×*Ñ*°HÐ*Ó=ˆØ"×2Ñ2¸HÐ2ÓEˆØ-1×-RÑ-RØ")§+¡+Ð.>Ó"?ð .Só .
Ð#ð
 $(×#=Ñ#=Ø1Ø1ØØ’M˜rØ%Ø-×1Ñ1Ð2EÀuÓMØ(CØ+ð $>ó 	$
Ðð 3Ð&Ð2¨'Ð2ˆð  gÑ-Ø+7ˆGÐ'Ñ(àˆr   c                 ó²   •— t        |«       t        ‰| �	  |||||¬«      }|j                  dd«       |j                  dd«       |j                  dd«       |S )zÀ
        Transform request using parent AnthropicConfig, then remove unsupported params.
        Azure Anthropic doesn't support extra_body, max_retries, or stream_options parameters.
        )r"   r#   r   r$   r!   r   NÚmax_retriesÚstream_options)r   ÚsuperÚtransform_requestr   )r   r"   r#   r   r$   r!   ÚdataÚ	__class__s          €r   rB   z&AzureAnthropicConfig.transform_requestl   sb   ø€ ô 	/¨Ô?ä‘gÑ/ØØØ+Ø)Øð 0ó 
ˆð 	�‰�˜tÔ$Ø�‰� Ô%Ø�‰Ð! 4Ô(àˆr   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚpropertyÚstrr   Úboolr    r   Úlistr   r   r=   rB   Ú__classcell__)rD   s   @r   r   r      sí   ø„ ñð ð S¨4¡Zò ó ðð¨tó ð #Ø#ñ>àð>ð ð>ð Ð'Ñ(ð	>ð
 ð>ð Ð3Ñ3ð>ð �t‘ð>ð ˜‘*ð>ð 
ó>ð@àðð Ð'Ñ(ðð ð	ð
 ðð ðð 
÷ñ r   r   )rH   Útypingr   Ú*litellm.llms.anthropic.chat.transformationr   Úlitellm.llms.azure.common_utilsr   Úlitellm.types.llms.openair   Úlitellm.types.routerr   r   r   r   r   r   r   ú<module>rS      s<   ðñõ å FÝ 8Ý 6Ý 5ð,¸Dð ,ÀTó ,ô"i˜?õ ir   