
    ^h
                     ^    S r SSKrSSKrSSKrSSKrSSKJr    SS\R                  4S jjrg)z1
Runs when LLM Exceptions occur on LiteLLM Proxy
    N)LiteLLM_ErrorLogscompletion_responsec                 \  #    SSK Jn  SSKJnJn  UR                  S5      SL a  gUGb  UR                  SU S9  U R                  S	5      nUR                  R                  nU R                  S
S5      n	U R                  S0 5      n
[        R                  " U
5      n
U
R                  5        H  u  p[        U5      nUSS nM     Sn [        UR                  5      nU R                  S0 5      =(       d    0 nUR                  S0 5      =(       d    0 nUR                  S0 5      R                  SS5      nUR                  SS5      n[        R                   " XS9n[        U5      n[#        [        [$        R&                  " 5       5      UUU R                  S
5      U
UUUUU R                  S5      U R                  S5      S9nUR)                  5       n[*        R,                  " US   5      US'   UR.                  R0                  R3                  US9I Sh  vN   g! [         a     GNJf = f N7f)z
Async Failure Handler - runs when LLM Exceptions occur on LiteLLM Proxy.
This function logs the errors to the Prisma DB

Can be disabled by setting the following on proxy_config.yaml:
```yaml
general_settings:
  disable_error_logs: True
```

r   )verbose_proxy_logger)general_settingsprisma_clientdisable_error_logsTNz%inside _PROXY_failure_handler kwargs=)extra	exceptionmodeloptional_paramsd   500litellm_paramsmetadata
model_infoid model_group)r   r   
start_timeend_time)
request_idr   model_idlitellm_model_namerequest_kwargsapi_baseexception_typestatus_codeexception_string	startTimeendTimer   )data)litellm._loggingr   litellm.proxy.proxy_serverr   r   getdebug	__class____name__copydeepcopyitemsstrr   	Exceptionlitellmget_api_baser   uuiduuid4
model_dumpjsondumpsdblitellm_errorlogscreate)kwargsr   r   r   r   r   r   
_exception_exception_type_model_optional_paramskv_status_code_litellm_params	_metadata	_model_id_model_groupr   _exception_string	error_logerror_log_dicts                         c/home/james-whalen/.local/lib/python3.13/site-packages/litellm/proxy/hooks/proxy_failure_handler.py_PROXY_failure_handlerrH      s    " 6J01T9 ""36 	# 	
 ZZ,
$..77GT*!::&7<==)9:$**,DAAA$3A - 	z556L
 !**%5r:@b#''
B7=2	MM,377bA	 }}]B7''fV
O%4::<($%zz'2+*$.jj.JJz*
	 #--/+/::nEU6V+W'(0077 8 
 	
 	
 	A  		8	
s7   CH,H D7H,H*H,
H'#H,&H''H,)NN)	__doc__r)   r3   r0   r.   litellm.proxy._typesr   ModelResponserH        rG   <module>rN      s8        2 	J	 ..J	rM   