
    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' G d1 d2e          Z( G d3 d4e          Z)dS )5    )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SubjectTokenProviderErrorWebSocketConnectionClosedErrorWebSocketQueueFullErrorc                      e Zd ZdS )OpenAIErrorN__name__
__module____qualname__     Y/home/ubuntu/.hermes/hermes-agent/venv/lib/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%   r1   z"SubjectTokenProviderError.__init__+   s&    !!! r$   )r*   r+   r)   r(   r,   r-   r    r!   r"   __annotations__r1   __classcell__r3   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@   )r0   r1   r;   r*   r=   r
   r   r   r   r   r+   getr>   r?   r@   )r2   r*   r;   r=   r3   s       r%   r1   zAPIError.__init__C   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+   r;   r:   r=   r<   r,   r-   )r    r!   r"   r5   r>   r?   r1   r6   r7   s   @r%   r9   r9   0   s         LLL DE         r$   r9   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=   r<   r*   
str | Noner,   r-   c                   t                                          |pd|j        |           || _        |j        | _        d S )Nz1Data returned by API invalid for expected schema.r=   )r0   r1   r;   r)   rI   )r2   r)   r=   r*   r3   s       r%   r1   z#APIResponseValidationError.__init__W   sE    W$WYaYiptuuu #/r$   )r)   rG   r=   r<   r*   rK   r,   r-   r4   r7   s   @r%   rF   rF   S   sd         _c 0 0 0 0 0 0 0 0 0 0 0 0r$   rF   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.rG   r)   rH   rI   rK   
request_idr*   r+   r=   r<   r,   r-   c                   t                                          ||j        |           || _        |j        | _        |j                            d          | _        d S )NrM   zx-request-id)r0   r1   r;   r)   rI   headersrD   rP   )r2   r*   r)   r=   r3   s       r%   r1   zAPIStatusError.__init__d   sS    ("2>>> #/"*..~>>r$   )r*   r+   r)   rG   r=   r<   r,   r-   r    r!   r"   __doc__r5   r1   r6   r7   s   @r%   rO   rO   ]   si         FF? ? ? ? ? ? ? ? ? ?r$   rO   c                  &     e Zd Zddd
 fd	Z xZS )APIConnectionErrorzConnection error.rJ   r*   r+   r;   r:   r,   r-   c               P    t                                          ||d            d S )NrM   r0   r1   )r2   r*   r;   r3   s      r%   r1   zAPIConnectionError.__init__l   s(    '55555r$   )r*   r+   r;   r:   r,   r-   r    r!   r"   r1   r6   r7   s   @r%   rV   rV   k   sJ        )< 6 6 6 6 6 6 6 6 6 6 6 6r$   rV   c                        e Zd Zd fdZ xZS )APITimeoutErrorr;   r:   r,   r-   c                N    t                                          d|           d S )NzRequest timed out.)r*   r;   rX   )r2   r;   r3   s     r%   r1   zAPITimeoutError.__init__q   s'    !5wGGGGGr$   )r;   r:   r,   r-   rY   r7   s   @r%   r[   r[   p   sG        H H H H H H H H H Hr$   r[   c                      e Zd ZU dZded<   dS )r   i  zLiteral[400]rI   Nr    r!   r"   rI   r5   r#   r$   r%   r   r   u   #          #K######r$   r   c                      e Zd ZU dZded<   dS )r   i  zLiteral[401]rI   Nr^   r#   r$   r%   r   r   y   r_   r$   r   c                  ,     e Zd ZU ded<   d
 fd	Z xZS )r   zOptional[OAuthErrorCode]errorr)   rG   r=   r<   r,   r-   c               F   d}d }t          |          rC|                    d          }|                    d          }|rt          |t                    r|}t	                                          |||           t          t          t                   |          | _	        d S )NzOAuth authentication error.rb   error_description)r)   r=   )
r
   rD   
isinstancer+   r0   r1   r   r   r   rb   )r2   r)   r=   r*   rb   descriptionr3   s         r%   r1   zOAuthError.__init__   s    /4== 	&HHW%%E((#677K &z+s;; &%8$???(>2E::


r$   )r)   rG   r=   r<   r,   r-   r4   r7   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]rI   Nr^   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]rI   Nr^   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]rI   Nr^   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]rI   Nr^   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]rI   Nr^   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 - )usager0   r1   rn   )r2   rn   msgr3   s      r%   r1   z LengthFinishReasonError.__init__   sL    P 	,+)+++C$r$   )rn   r   r,   r-   r4   r7   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 filterrX   )r2   r3   s    r%   r1   z'ContentFilterFinishReasonError.__init__   s,    a	
 	
 	
 	
 	
r$   )r,   r-   rY   r7   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"   rT   r#   r$   r%   r   r      s        {{{{r$   r   c                  0     e Zd ZU dZded<   d	 fdZ xZS )
r   z?Raised when a WebSocket connection closes with unsent messages.	list[str]unsent_messagesr*   r+   r,   r-   c               X    t                                          |           || _        d S r/   )r0   r1   rx   )r2   r*   rx   r3   s      r%   r1   z'WebSocketConnectionClosedError.__init__   s)    !!!.r$   )r*   r+   rx   rw   r,   r-   rS   r7   s   @r%   r   r      sQ         II/ / / / / / / / / /r$   r   c                      e Zd ZdZdS )r   zMRaised when the outgoing WebSocket message queue exceeds its byte-size limit.Nru   r#   r$   r%   r   r      s        WWDr$   r   )*
__future__r   typingr   r   r   r   typing_extensionsr   httpx_utilsr
   _modelsr   types.shared.oauth_error_coder   
types.chatr   __all__	Exceptionr   r   r9   rF   rO   rV   r[   r   r   r   r   r   r   r   r   r   r   r   
ValueErrorr   r   r   r#   r$   r%   <module>r      sH   # " " " " " 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 % % %"
 
 
 
 
[ 
 
 
| | | | |: | | |/ / / / /[ / / /	 	 	 	 	k 	 	 	 	 	r$   