o
    ưie                     @   s\   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 dl
mZ G dd de	Zd	S )
    )HTTPException)verbose_logger)verbose_proxy_logger)	DualCache)CustomLogger)UserAPIKeyAuthc                   @   s.   e Zd Zdd ZdedededefddZd	S )
_PROXY_MaxBudgetLimiterc                 C   s   d S )N )selfr	   r	   ]/home/app/Keep/.python/lib/python3.10/site-packages/litellm/proxy/hooks/max_budget_limiter.py__init__   s   z _PROXY_MaxBudgetLimiter.__init__user_api_key_dictcachedata	call_typec           
   
      s   z@t d |j d}|j||jdI d H }|d u rW d S |d }|d }|d u r.W d S |d u r5W d S ||kr?tdddW d S  tyO }	 z|	d }	~	w tyk }	 ztd		t
|	 W Y d }	~	d S d }	~	ww )
Nz'Inside Max Budget Limiter Pre-Call HookZ_user_api_key_user_id)parent_otel_span
max_budgetZspendi  zMax budget limit reached.)status_codedetailzXlitellm.proxy.hooks.max_budget_limiter.py::async_pre_call_hook(): Exception occured - {})r   debugZuser_idZasync_get_cacher   r   	Exceptionr   	exceptionformatstr)
r
   r   r   r   r   	cache_keyZuser_rowr   Z
curr_spender	   r	   r   async_pre_call_hook   s:   
z+_PROXY_MaxBudgetLimiter.async_pre_call_hookN)	__name__
__module____qualname__r   r   r   dictr   r   r	   r	   r	   r   r   
   s    r   N)Zfastapir   Zlitellmr   Zlitellm._loggingr   Zlitellm.caching.cachingr   Z"litellm.integrations.custom_loggerr   Zlitellm.proxy._typesr   r   r	   r	   r	   r   <module>   s    