o
    ưi$                     @   s6   d Z ddlmZmZmZmZ ddlZG dd dZdS )<HTTP client for making requests to the LiteLLM proxy server.    )AnyDictOptionalUnionNc                   @   s   e Zd ZdZddedee defd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dZdS )
HTTPClientr   N   base_urlapi_keytimeoutc                 C   s   | d| _|| _|| _dS )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    r   W/home/app/Keep/.python/lib/python3.10/site-packages/litellm/proxy/client/http_client.py__init__
   s   
zHTTPClient.__init__)datajsonheadersmethodurir   r   r   kwargsreturnc          
   	   K   sn   | j  d|d }i }|r|| | jrd| j |d< tjd|||||| jd|}	|	  |	 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   Nr   )	r   lstripupdater   requestsrequestr   raise_for_statusr   )
r   r   r   r   r   r   r   r   Zrequest_headersresponser   r   r   r!      s$   2
zHTTPClient.request)Nr   )__name__
__module____qualname____doc__strr   intr   r   r   r   listbytesr!   r   r   r   r   r      s*    	r   )r'   typingr   r   r   r   r    r   r   r   r   r   <module>   s    