
    	D,j                     v   d dl mZ d dlmZ e G d d                      Z eddd           eddd           ed	dd           ed
dd           eddd           eddd           eddd           eddd           eddd           eddd           eddd           eddd           eddd           eddd           eddd           eddd           eddd           eddd           eddd           ed dd           ed!dd           ed"dd#          gZ G d$ d%          ZdS )&    )	dataclass)dumpc                   .    e Zd ZU eed<   eed<   eed<   dS )ExInfonameretrydescriptionN)__name__
__module____qualname__str__annotations__bool     _/home/rurouni/.local/share/uv/tools/aider-chat/lib/python3.11/site-packages/aider/exceptions.pyr   r      s0         
IIIKKKr   r   APIConnectionErrorTNAPIErrorAPIResponseValidationErrorAuthenticationErrorFzEThe API provider is not able to authenticate you. Check your API key.AzureOpenAIErrorBadGatewayErrorz2The API provider's servers are down or overloaded.BadRequestErrorBudgetExceededErrorContentPolicyViolationErrorzRThe API provider has refused the request due to a safety policy about the content.ContextWindowExceededErrorImageFetchErrorz8The API provider was unable to fetch one or more images.InternalServerErrorInvalidRequestErrorJSONSchemaValidationErrorNotFoundErrorOpenAIErrorRateLimitErrorzLThe API provider has rate limited you. Try again later or check your quotas.RouterRateLimitErrorServiceUnavailableErrorUnprocessableEntityErrorUnsupportedParamsErrorTimeoutzXThe API provider timed out without returning a response. They may be down or overloaded.c                   T    e Zd Z e            Zd eD             Zd ZddZd Z	d Z
dS )	LiteLLMExceptionsc                     i | ]
}|j         |S r   )r   ).0exis     r   
<dictcomp>zLiteLLMExceptions.<dictcomp>9   s    :::ch:::r   c                 .    |                                   d S N)_loadselfs    r   __init__zLiteLLMExceptions.__init__;   s    

r   Fc                 6   dd l }t          |          D ]U}|                    d          r>t          t	          ||          t
                    r|| j        vrt          | d          V| j        D ]'}t	          ||          }| j        |         | j        |<   (d S )Nr   Errorz1 is in litellm but not in aider's exceptions list)	litellmdirendswith
issubclassgetattrBaseExceptionexception_info
ValueError
exceptions)r3   strictr7   varexs        r   r1   zLiteLLMExceptions._load>   s    w<< 	` 	`C ||G$$ `GGS4I4I=)Y)Y `d111$%^%^%^___& 	; 	;C#&&B"&"5c":DOB	; 	;r   c                 *    t          | j                  S r0   )tupler?   r2   s    r   exceptions_tuplez"LiteLLMExceptions.exceptions_tupleM   s    T_%%%r   c                    ddl }|j        |j        u rUdt          |          v rt	          ddd          S dt          |          v r"dt          |          v rt	          dd	d
          S |j        |j        u r:t          |                                          }d|v rd|v rt	          ddd          S | j                            |j        t	          ddd                    S )z0Return the ExInfo for a given exception instancer   Nboto3r   FzYou need to: pip install boto3OpenrouterExceptionz	'choices'Tz[OpenRouter or the upstream API provider is down, overloaded or rate limiting your requests.zinsufficient creditsz
"code":402r   z?Insufficient credits with the API provider. Please add credits.)	r7   	__class__r   r   r   r   lowerr?   get)r3   rB   r7   err_strs       r   get_ex_infozLiteLLMExceptions.get_ex_infoP   s    <7555#b''!!2E;[\\\$B//K3r774J4J(3	   <7+++"ggmmooG%00\W5L5LU   ""2<dD1I1IJJJr   N)F)r
   r   r   dictr?   
EXCEPTIONSr=   r4   r1   rE   rM   r   r   r   r*   r*   7   sx        J::z:::N  ; ; ; ;& & &K K K K Kr   r*   )dataclassesr   
aider.dumpr   r   rO   r*   r   r   r   <module>rR      sO   ! ! ! ! ! !               Ft,,
F:tT""
F't44
FO 
 FtT**
Fd$XYY
FeT**
F $--
F%\ 
 F'55
Fe%_``
F $(\]]
F $--
F&d33
F?E4((
F=$%%
FV 
 F!4..
F$d,`aa
F%tT22
F#T400
Fb E'
T5K 5K 5K 5K 5K 5K 5K 5K 5K 5Kr   