
    i+                       d dl mZ d dlmZmZmZmZ d dlmZ d dl	Z	ddl
mZ ddlmZ ddlmZ erdd	lmZ g d
Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d d e          Z G d! d"e          Z G d# d$e          Z  G d% d&e          Z! G d' d(e          Z" G d) d*e          Z# G d+ d,e          Z$ G d- d.e          Z% G d/ d0e&          Z'dS )1    )annotations)TYPE_CHECKINGAnyOptionalcast)LiteralN   )is_dict)construct_type)OAuthErrorCode)ChatCompletion)BadRequestErrorAuthenticationError
OAuthErrorPermissionDeniedErrorNotFoundErrorConflictErrorUnprocessableEntityErrorRateLimitErrorInternalServerErrorLengthFinishReasonErrorContentFilterFinishReasonErrorInvalidWebhookSignatureErrorSubjectTokenProviderErrorc                      e Zd ZdS )OpenAIErrorN__name__
__module____qualname__     T/root/.hermes/hermes-agent/venv/lib64/python3.11/site-packages/openai/_exceptions.pyr   r   "           Dr"   r   c                  2     e Zd ZU ded<   ddd
 fd	Z xZS )r   httpx.Response | NoneresponseN)r'   messagestrreturnNonec               X    t                                          |           || _        d S )N)super__init__r'   )selfr(   r'   	__class__s      r#   r.   z"SubjectTokenProviderError.__init__)   s&    !!! r"   )r(   r)   r'   r&   r*   r+   r   r   r    __annotations__r.   __classcell__r0   s   @r#   r   r   &   sX         ####JN ! ! ! ! ! ! ! ! ! ! ! !r"   r   c                  h     e Zd ZU ded<   ded<   ded<   	 dZded	<   dZded
<   ded<   d fdZ xZS )APIErrorr)   r(   httpx.Requestrequestobject | NonebodyNzOptional[str]codeparamtyper*   r+   c          	     r   t                                          |           || _        || _        || _        t          |          rt          t          t          t          t                   |                    d                              | _        t          t          t          t          t                   |                    d                              | _        t          t          t          t          |                    d                              | _        d S d | _        d | _        d | _        d S )Nr;   )type_valuer<   r=   )r-   r.   r8   r(   r:   r
   r   r   r   r   r)   getr;   r<   r=   )r/   r(   r8   r:   r0   s       r#   r.   zAPIError.__init__A   s    !!!	4== 	S.x}DHHU[L\L\"]"]"]^^DIc>TXXV]M^M^#_#_#_``DJS.s$((6BRBR"S"S"STTDIIIDIDJDIIIr"   )r(   r)   r8   r7   r:   r9   r*   r+   )r   r   r    r2   r;   r<   r.   r3   r4   s   @r#   r6   r6   .   s         LLL DE         r"   r6   c                  <     e Zd ZU ded<   ded<   ddd fdZ xZS )APIResponseValidationErrorhttpx.Responser'   intstatus_codeNr(   r:   r9   r(   
str | Noner*   r+   c                   t                                          |pd|j        |           || _        |j        | _        d S )Nz1Data returned by API invalid for expected schema.r:   )r-   r.   r8   r'   rF   )r/   r'   r:   r(   r0   s       r#   r.   z#APIResponseValidationError.__init__U   sE    W$WYaYiptuuu #/r"   )r'   rD   r:   r9   r(   rH   r*   r+   r1   r4   s   @r#   rC   rC   Q   sd         _c 0 0 0 0 0 0 0 0 0 0 0 0r"   rC   c                  D     e Zd ZU dZded<   ded<   ded<   d fdZ xZS )APIStatusErrorz<Raised when an API response has a status code of 4xx or 5xx.rD   r'   rE   rF   rH   
request_idr(   r)   r:   r9   r*   r+   c                   t                                          ||j        |           || _        |j        | _        |j                            d          | _        d S )NrJ   zx-request-id)r-   r.   r8   r'   rF   headersrA   rM   )r/   r(   r'   r:   r0   s       r#   r.   zAPIStatusError.__init__b   sS    ("2>>> #/"*..~>>r"   )r(   r)   r'   rD   r:   r9   r*   r+   )r   r   r    __doc__r2   r.   r3   r4   s   @r#   rL   rL   [   si         FF? ? ? ? ? ? ? ? ? ?r"   rL   c                  &     e Zd Zddd
 fd	Z xZS )APIConnectionErrorzConnection error.rG   r(   r)   r8   r7   r*   r+   c               P    t                                          ||d            d S )NrJ   r-   r.   )r/   r(   r8   r0   s      r#   r.   zAPIConnectionError.__init__j   s(    '55555r"   )r(   r)   r8   r7   r*   r+   r   r   r    r.   r3   r4   s   @r#   rR   rR   i   sJ        )< 6 6 6 6 6 6 6 6 6 6 6 6r"   rR   c                        e Zd Zd fdZ xZS )APITimeoutErrorr8   r7   r*   r+   c                N    t                                          d|           d S )NzRequest timed out.)r(   r8   rT   )r/   r8   r0   s     r#   r.   zAPITimeoutError.__init__o   s'    !5wGGGGGr"   )r8   r7   r*   r+   rU   r4   s   @r#   rW   rW   n   sG        H H H H H H H H H Hr"   rW   c                      e Zd ZU dZded<   dS )r   i  zLiteral[400]rF   Nr   r   r    rF   r2   r!   r"   r#   r   r   s   #          #K######r"   r   c                      e Zd ZU dZded<   dS )r   i  zLiteral[401]rF   NrZ   r!   r"   r#   r   r   w   r[   r"   r   c                  ,     e Zd ZU ded<   d
 fd	Z xZS )r   zOptional[OAuthErrorCode]errorr'   rD   r:   r9   r*   r+   c               F   d}d }t          |          rC|                    d          }|                    d          }|rt          |t                    r|}t	                                          |||           t          t          t                   |          | _	        d S )NzOAuth authentication error.r^   error_description)r'   r:   )
r
   rA   
isinstancer)   r-   r.   r   r   r   r^   )r/   r'   r:   r(   r^   descriptionr0   s         r#   r.   zOAuthError.__init__~   s    /4== 	&HHW%%E((#677K &z+s;; &%8$???(>2E::


r"   )r'   rD   r:   r9   r*   r+   r1   r4   s   @r#   r   r   {   sK         ####; ; ; ; ; ; ; ; ; ;r"   r   c                      e Zd ZU dZded<   dS )r   i  zLiteral[403]rF   NrZ   r!   r"   r#   r   r      r[   r"   r   c                      e Zd ZU dZded<   dS )r   i  zLiteral[404]rF   NrZ   r!   r"   r#   r   r      r[   r"   r   c                      e Zd ZU dZded<   dS )r   i  zLiteral[409]rF   NrZ   r!   r"   r#   r   r      r[   r"   r   c                      e Zd ZU dZded<   dS )r   i  zLiteral[422]rF   NrZ   r!   r"   r#   r   r      r[   r"   r   c                      e Zd ZU dZded<   dS )r   i  zLiteral[429]rF   NrZ   r!   r"   r#   r   r      r[   r"   r   c                      e Zd ZdS )r   Nr   r!   r"   r#   r   r      r$   r"   r   c                  .     e Zd ZU ded<   	 d fdZ xZS )r   r   
completionr*   r+   c                   d}|j         r|d|j          z  }t                                          |           || _        d S )Nz@Could not parse response content as the length limit was reachedz - )usager-   r.   rj   )r/   rj   msgr0   s      r#   r.   z LengthFinishReasonError.__init__   sL    P 	,+)+++C$r"   )rj   r   r*   r+   r1   r4   s   @r#   r   r      sP         % % % % % % % % % %r"   r   c                        e Zd Zd fdZ xZS )r   r*   r+   c                J    t                                          d           d S )NzRCould not parse response content as the request was rejected by the content filterrT   )r/   r0   s    r#   r.   z'ContentFilterFinishReasonError.__init__   s,    a	
 	
 	
 	
 	
r"   )r*   r+   rU   r4   s   @r#   r   r      s=        
 
 
 
 
 
 
 
 
 
r"   r   c                      e Zd ZdZdS )r   zqRaised when a webhook signature is invalid, meaning the computed signature does not match the expected signature.N)r   r   r    rP   r!   r"   r#   r   r      s        {{{{r"   r   )(
__future__r   typingr   r   r   r   typing_extensionsr   httpx_utilsr
   _modelsr   types.shared.oauth_error_coder   
types.chatr   __all__	Exceptionr   r   r6   rC   rL   rR   rW   r   r   r   r   r   r   r   r   r   r   r   
ValueErrorr   r!   r"   r#   <module>r|      s   # " " " " " 5 5 5 5 5 5 5 5 5 5 5 5 % % % % % %        # # # # # # 9 9 9 9 9 9 +******  "	 	 	 	 	) 	 	 	! ! ! ! ! ! ! !         {      F0 0 0 0 0 0 0 0? ? ? ? ?X ? ? ?6 6 6 6 6 6 6 6
H H H H H( H H H
$ $ $ $ $n $ $ $$ $ $ $ $. $ $ $; ; ; ; ;$ ; ; ;"$ $ $ $ $N $ $ $$ $ $ $ $N $ $ $$ $ $ $ $N $ $ $$ $ $ $ $~ $ $ $$ $ $ $ $^ $ $ $	 	 	 	 	. 	 	 	% % % % %k % % %"
 
 
 
 
[ 
 
 
| | | | |: | | | | |r"   