
    
@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!dS )*    )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dS )OpenAIErrorN__name__
__module____qualname__     F/var/www/piapp/venv/lib/python3.11/site-packages/openai/_exceptions.pyr   r              Dr   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typereturnNonec          	     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+   )super__init__r&   r$   r(   r
   r   r   r   r   r#   getr)   r*   r+   )selfr$   r&   r(   	__class__s       r   r2   zAPIError.__init__5   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   __annotations__r)   r*   r2   __classcell__r5   s   @r   r"   r"   "   s         LLL 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$   r(   r'   r$   
str | Noner,   r-   c                   t                                          |pd|j        |           || _        |j        | _        d S )Nz1Data returned by API invalid for expected schema.r(   )r1   r2   r&   r<   r>   )r4   r<   r(   r$   r5   s       r   r2   z#APIResponseValidationError.__init__I   sE    W$WYaYiptuuu #/r   )r<   r;   r(   r'   r$   r@   r,   r-   r   r   r   r6   r2   r7   r8   s   @r   r:   r:   E   sd         _c 0 0 0 0 0 0 0 0 0 0 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>   r@   
request_idr$   r#   r(   r'   r,   r-   c                   t                                          ||j        |           || _        |j        | _        |j                            d          | _        d S )NrB   zx-request-id)r1   r2   r&   r<   r>   headersr3   rF   )r4   r$   r<   r(   r5   s       r   r2   zAPIStatusError.__init__V   sS    ("2>>> #/"*..~>>r   )r$   r#   r<   r;   r(   r'   r,   r-   )r   r   r   __doc__r6   r2   r7   r8   s   @r   rE   rE   O   si         FF? ? ? ? ? ? ? ? ? ?r   rE   c                  &     e Zd Zddd
 fd	Z xZS )APIConnectionErrorzConnection error.r?   r$   r#   r&   r%   r,   r-   c               P    t                                          ||d            d S )NrB   r1   r2   )r4   r$   r&   r5   s      r   r2   zAPIConnectionError.__init__^   s(    '55555r   )r$   r#   r&   r%   r,   r-   r   r   r   r2   r7   r8   s   @r   rK   rK   ]   sJ        )< 6 6 6 6 6 6 6 6 6 6 6 6r   rK   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&   rM   )r4   r&   r5   s     r   r2   zAPITimeoutError.__init__c   s'    !5wGGGGGr   )r&   r%   r,   r-   rN   r8   s   @r   rP   rP   b   sG        H H H H H H H H H Hr   rP   c                      e Zd ZU dZded<   dS )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<   dS )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<   dS )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<   dS )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<   dS )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<   dS )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<   dS )r   i  zLiteral[429]r>   NrS   r   r   r   r   r      rT   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 - )usager1   r2   r]   )r4   r]   msgr5   s      r   r2   z LengthFinishReasonError.__init__   sL    P 	,+)+++C$r   )r]   r   r,   r-   rC   r8   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 filterrM   )r4   r5   s    r   r2   z'ContentFilterFinishReasonError.__init__   s,    a	
 	
 	
 	
 	
r   )r,   r-   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 5 5 5 5 5 5 5 5 5 5 % % % % % %        # # # # # # +******  	 	 	 	 	) 	 	 	         {      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   