
    i                     p    d Z ddlmZmZmZmZmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ er	  G d de      Zy	)
z[
Azure Anthropic transformation config - extends AnthropicConfig with Azure authentication
    )TYPE_CHECKINGDictListOptionalUnion)AnthropicConfig)BaseAzureLLM)AllMessageValues)GenericLiteLLMParamsc                        e Zd ZdZedee   fd       Z	 	 ddedede	e
   dedeeef   d	ee   d
ee   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.
    returnc                      y)Nazure_ai )selfs    /Users/manta/Documents/Projects/TheRoad-I1/.venv/lib/python3.12/site-packages/litellm/llms/azure_ai/anthropic/transformation.pycustom_llm_providerz(AzureAnthropicConfig.custom_llm_provider   s        headersmodelmessagesoptional_paramslitellm_paramsapi_keyapi_basec                 |   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   )
isinstancedictr   r   r	    _base_validate_azure_environmentget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#   r(   r%   r&   r'   anthropic_headerss                    r   validate_environmentz)AzureAnthropicConfig.validate_environment   s   " nd+9N:!GN!GIw!G!5!G!G!/!I3G3I199-4"* ??,>

  ##G,!666I!77e7D11'++M: 2 
 ##X#6++X+>&*&K&K")++.>"? 'L '
#
 !6611Mr%-112EuM(C+ 7 	
 3&2'2 g-+7G'(r   c                     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   
extra_bodyNmax_retriesstream_options)supertransform_requestpop)r   r   r   r   r   r   data	__class__s          r   r<   z&AzureAnthropicConfig.transform_request[   sZ     w(+) ) 
 	t$%!4(r   )NN)__name__
__module____qualname____doc__propertyr   strr   r*   r   r
   r   r   r   r6   r<   __classcell__)r?   s   @r   r   r      s     Xc]   "&"&@@ @ '(	@
 @ d$889@ #@ 3-@ 
@D '( 	
   
 r   r   N)rC   typingr   r   r   r   r   *litellm.llms.anthropic.chat.transformationr   litellm.llms.azure.common_utilsr	   litellm.types.llms.openair
   litellm.types.routerr   r   r   r   r   <module>rL      s2    > = F 8 6 5g? gr   