
    h$                     <    d Z ddlmZmZmZmZ ddlZ G d d      Zy)<HTTP client for making requests to the LiteLLM proxy server.    )AnyDictOptionalUnionNc                       e Zd ZdZddedee   defdZddddded	ed
eee	ee
f   eef      deee	ee
f   ef      dee	eef      de
de
fdZy)
HTTPClientr   Nbase_urlapi_keytimeoutc                 L    |j                  d      | _        || _        || _        y)zInitialize the HTTP client.

        Args:
            base_url: Base URL of the LiteLLM proxy server
            api_key: Optional API key for authentication
            timeout: Request timeout in seconds (default: 30)
        /N)rstrip	_base_url_api_key_timeout)selfr
   r   r   s       \/var/www/Befach/backend/env/lib/python3.12/site-packages/litellm/proxy/client/http_client.py__init__zHTTPClient.__init__
   s"     "-    )datajsonheadersmethodurir   r   r   kwargsreturnc          
      4   | j                    d|j                  d       }i }|r|j                  |       | j                  rd| j                   |d<   t	        j
                  d|||||| j                  d|}	|	j                          |	j                         S )a  Make an HTTP request to the LiteLLM proxy server.

        This method is used to make generic requests to the LiteLLM proxy
        server, when there is not a specific client or method for the request.

        Args:
            method: HTTP method (GET, POST, PUT, DELETE, etc.)
            uri: URI path (will be appended to base_url) (e.g., "/credentials")
            data: (optional) Dictionary, list of tuples, bytes, or file-like
                object to send in the body of the request.
            json: (optional) A JSON serializable Python object to send in the body
                of the request.
            headers: (optional) Dictionary of HTTP headers to send with the request.
            **kwargs: Additional keyword arguments to pass to the request.

        Returns:
            Parsed JSON response from the server

        Raises:
            requests.exceptions.RequestException: If the request fails
            ValueError: If the response is not valid JSON

        Example:
            >>> client.http.request("POST", "/health/test_connection", json={
                "litellm_params": {
                    "model": "gpt-4",
                    "custom_llm_provider": "azure_ai",
                    "litellm_credential_name": None,
                    "api_key": "6xxxxxxx",
                    "api_base": "https://litellm8397336933.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-10-21",
                },
                "mode": "chat",
            })
            {'status': 'error',
             'result': {'model': 'gpt-4',
             'custom_llm_provider': 'azure_ai',
             'litellm_credential_name': None,
             ...
        r   zBearer Authorization)r   urlr   r   r   r    )	r   lstripupdater   requestsrequestr   raise_for_statusr   )
r   r   r   r   r   r   r   r    request_headersresponses
             r   r%   zHTTPClient.request   s    d  #**S/!23 ""7+==18/HOO,## 
#MM
 
 	!!# }}r   )N   )__name__
__module____qualname____doc__strr   intr   r   r   r   listbytesr%   r!   r   r   r	   r	      s    F
  
 x} 
 c 
 " >B6:,0II I
 uT#s(^T589:I uT#s(^T123I $sCx.)I I 
Ir   r	   )r-   typingr   r   r   r   r$   r	   r!   r   r   <module>r3      s    B - - X Xr   