
    zvh                       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 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#y),    )annotations)TYPE_CHECKINGAnyOptionalcast)LiteralN   )is_dict)construct_type)ChatCompletion)BadRequestErrorAuthenticationErrorPermissionDeniedErrorNotFoundErrorConflictErrorUnprocessableEntityErrorRateLimitErrorInternalServerErrorLengthFinishReasonErrorContentFilterFinishReasonErrorInvalidWebhookSignatureErrorc                      e Zd Zy)OpenAIErrorN__name__
__module____qualname__     J/var/www/html/luna/venv/lib/python3.12/site-packages/openai/_exceptions.pyr   r          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 )APIErrorstrmessagehttpx.Requestrequestobject | NonebodyNzOptional[str]codeparamtypec          	        t         |   |       || _        || _        || _        t        |      rt        t        t        t        t           |j                  d                  | _        t        t        t        t        t           |j                  d                  | _        t        t        t        t        |j                  d                  | _        y d | _        d | _        d | _        y )Nr*   )type_valuer+   r,   )super__init__r'   r%   r)   r
   r   r   r   r   r$   getr*   r+   r,   )selfr%   r'   r)   	__class__s       r    r1   zAPIError.__init__6   s    !	4=S.x}DHHU[L\"]^DIc>TXXV]M^#_`DJS.s$((6BR"STDIDIDJDIr   )r%   r$   r'   r&   r)   r(   returnNone)r   r   r   __annotations__r*   r+   r1   __classcell__r4   s   @r    r#   r#   #   s?    L
 D-E=
 r   r#   c                  <     e Zd ZU ded<   ded<   ddd fdZ xZS )	APIResponseValidationErrorhttpx.Responseresponseintstatus_codeNr%   c               v    t         |   |xs d|j                  |       || _        |j                  | _        y )Nz1Data returned by API invalid for expected schema.r)   )r0   r1   r'   r=   r?   )r3   r=   r)   r%   r4   s       r    r1   z#APIResponseValidationError.__init__J   s:    W$WYaYiYiptu #//r   )r=   r<   r)   r(   r%   
str | Noner5   r6   r   r   r   r7   r1   r8   r9   s   @r    r;   r;   F   s    _c 0 0r   r;   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.r<   r=   r>   r?   rC   
request_idc                   t         |   ||j                  |       || _        |j                  | _        |j
                  j                  d      | _        y )NrB   zx-request-id)r0   r1   r'   r=   r?   headersr2   rG   )r3   r%   r=   r)   r4   s       r    r1   zAPIStatusError.__init__W   sJ    ("2"2> #//"**..~>r   )r%   r$   r=   r<   r)   r(   r5   r6   )r   r   r   __doc__r7   r1   r8   r9   s   @r    rF   rF   P   s"    F? ?r   rF   c                  &     e Zd Zddd fdZ xZS )APIConnectionErrorzConnection error.r@   c               *    t         |   ||d        y )NrB   r0   r1   )r3   r%   r'   r4   s      r    r1   zAPIConnectionError.__init___   s    '5r   )r%   r$   r'   r&   r5   r6   r   r   r   r1   r8   r9   s   @r    rL   rL   ^   s    )< 6 6r   rL   c                        e Zd Zd fdZ xZS )APITimeoutErrorc                (    t         |   d|       y )NzRequest timed out.)r%   r'   rN   )r3   r'   r4   s     r    r1   zAPITimeoutError.__init__d   s    !5wGr   )r'   r&   r5   r6   rO   r9   s   @r    rQ   rQ   c   s    H Hr   rQ   c                      e Zd ZU dZded<   y)r   i  zLiteral[400]r?   Nr   r   r   r?   r7   r   r   r    r   r   h        #K#r   r   c                      e Zd ZU dZded<   y)r   i  zLiteral[401]r?   NrT   r   r   r    r   r   l   rU   r   r   c                      e Zd ZU dZded<   y)r   i  zLiteral[403]r?   NrT   r   r   r    r   r   p   rU   r   r   c                      e Zd ZU dZded<   y)r   i  zLiteral[404]r?   NrT   r   r   r    r   r   t   rU   r   r   c                      e Zd ZU dZded<   y)r   i  zLiteral[409]r?   NrT   r   r   r    r   r   x   rU   r   r   c                      e Zd ZU dZded<   y)r   i  zLiteral[422]r?   NrT   r   r   r    r   r   |   rU   r   r   c                      e Zd ZU dZded<   y)r   i  zLiteral[429]r?   NrT   r   r   r    r   r      rU   r   r   c                      e Zd Zy)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   
completionc               r    d}|j                   r|d|j                    z  }t        | 	  |       || _        y )Nz@Could not parse response content as the length limit was reachedz - )usager0   r1   r^   )r3   r^   msgr4   s      r    r1   z LengthFinishReasonError.__init__   s=    PS))*++C$r   )r^   r   r5   r6   rD   r9   s   @r    r   r      s    % %r   r   c                        e Zd Zd fdZ xZS )r   c                $    t         |   d       y )NzRCould not parse response content as the request was rejected by the content filterrN   )r3   r4   s    r    r1   z'ContentFilterFinishReasonError.__init__   s    `	
r   )r5   r6   rO   r9   s   @r    r   r      s    
 
r   r   c                      e Zd ZdZy)r   zqRaised when a webhook signature is invalid, meaning the computed signature does not match the expected signature.N)r   r   r   rJ   r   r   r    r   r      s    {r   r   )$
__future__r   typingr   r   r   r   typing_extensionsr   httpx_utilsr
   _modelsr   
types.chatr   __all__	Exceptionr   r#   r;   rF   rL   rQ   r   r   r   r   r   r   r   r   r   r   
ValueErrorr   r   r   r    <module>ro      s    # 5 5 %   #*	) 	 {  F0 0?X ?6 6
H( H
$n $$. $$N $$N $$N $$~ $$^ $	. 	%k %"
[ 
|: |r   