
    g                       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!y)*    )annotations)TYPE_CHECKINGAnyOptionalcast)LiteralN   )is_dict)construct_type)ChatCompletion)
BadRequestErrorAuthenticationErrorPermissionDeniedErrorNotFoundErrorConflictErrorUnprocessableEntityErrorRateLimitErrorInternalServerErrorLengthFinishReasonErrorContentFilterFinishReasonErrorc                      e Zd Zy)OpenAIErrorN__name__
__module____qualname__     G/var/www/openai/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   r0   zAPIError.__init__5   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*   r0   __classcell__r3   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(   )r/   r0   r&   r<   r>   )r2   r<   r(   r$   r3   s       r   r0   z#APIResponseValidationError.__init__I   s:    W$WYaYiYiptu #//r   )r<   r;   r(   r'   r$   
str | Noner4   r5   r   r   r   r6   r0   r7   r8   s   @r   r:   r:   E   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>   rB   
request_idc                   t         |   ||j                  |       || _        |j                  | _        |j
                  j                  d      | _        y )NrA   zx-request-id)r/   r0   r&   r<   r>   headersr1   rF   )r2   r$   r<   r(   r3   s       r   r0   zAPIStatusError.__init__V   sJ    ("2"2> #//"**..~>r   )r$   r#   r<   r;   r(   r'   r4   r5   )r   r   r   __doc__r6   r0   r7   r8   s   @r   rE   rE   O   s"    F? ?r   rE   c                  &     e Zd Zddd fdZ xZS )APIConnectionErrorzConnection error.r?   c               *    t         |   ||d        y )NrA   r/   r0   )r2   r$   r&   r3   s      r   r0   zAPIConnectionError.__init__^   s    '5r   )r$   r#   r&   r%   r4   r5   r   r   r   r0   r7   r8   s   @r   rK   rK   ]   s    )< 6 6r   rK   c                        e Zd Zd fdZ xZS )APITimeoutErrorc                (    t         |   d|       y )NzRequest timed out.)r$   r&   rM   )r2   r&   r3   s     r   r0   zAPITimeoutError.__init__c   s    !5wGr   )r&   r%   r4   r5   rN   r8   s   @r   rP   rP   b   s    H Hr   rP   c                      e Zd ZU dZded<   y)r   i  zLiteral[400]r>   Nr   r   r   r>   r6   r   r   r   r   r   g        #K#r   r   c                      e Zd ZU dZded<   y)r   i  zLiteral[401]r>   NrS   r   r   r   r   r   k   rT   r   r   c                      e Zd ZU dZded<   y)r   i  zLiteral[403]r>   NrS   r   r   r   r   r   o   rT   r   r   c                      e Zd ZU dZded<   y)r   i  zLiteral[404]r>   NrS   r   r   r   r   r   s   rT   r   r   c                      e Zd ZU dZded<   y)r   i  zLiteral[409]r>   NrS   r   r   r   r   r   w   rT   r   r   c                      e Zd ZU dZded<   y)r   i  zLiteral[422]r>   NrS   r   r   r   r   r   {   rT   r   r   c                      e Zd ZU dZded<   y)r   i  zLiteral[429]r>   NrS   r   r   r   r   r      rT   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 - )usager/   r0   r]   )r2   r]   msgr3   s      r   r0   z LengthFinishReasonError.__init__   s=    PS))*++C$r   )r]   r   r4   r5   rC   r8   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 filterrM   )r2   r3   s    r   r0   z'ContentFilterFinishReasonError.__init__   s    `	
r   )r4   r5   rN   r8   s   @r   r   r      s    
 
r   r   )"
__future__r   typingr   r   r   r   typing_extensionsr   httpx_utilsr
   _modelsr   
types.chatr   __all__	Exceptionr   r"   r:   rE   rK   rP   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>rl      s    # 5 5 %   #*	) 	 {  F0 0?X ?6 6
H( H
$n $$. $$N $$N $$N $$~ $$^ $	. 	%k %"
[ 
r   