o
    ØRWj>  ã                   @  sÈ  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r6dd	lmZ g d
¢ZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd „ d eƒZG d!d"„ d"eƒZG d#d$„ d$eƒZ G d%d&„ d&eƒZ!G d'd(„ d(eƒZ"G d)d*„ d*eƒZ#G d+d,„ d,eƒZ$G d-d.„ d.eƒZ%G d/d0„ d0e&ƒZ'G d1d2„ d2eƒZ(G d3d4„ 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__© r"   r"   úa/home/esfera/Documents/content_generation/venv/lib/python3.10/site-packages/openai/_exceptions.pyr   $   ó    r   c                      s.   e Zd ZU ded< ddœd‡ fd	d
„Z‡  ZS )r   úhttpx.Response | NoneÚresponseN)r&   ÚmessageÚstrÚreturnÚNonec                  ó   t ƒ  |¡ || _d S ©N)ÚsuperÚ__init__r&   )Úselfr'   r&   ©Ú	__class__r"   r#   r.   +   ó   
z"SubjectTokenProviderError.__init__)r'   r(   r&   r%   r)   r*   ©r   r    r!   Ú__annotations__r.   Ú__classcell__r"   r"   r0   r#   r   (   s   
 r   c                      sZ   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d„Z‡  ZS )ÚAPIErrorr(   r'   úhttpx.RequestÚrequestúobject | NoneÚbodyNzOptional[str]ÚcodeÚparamÚtyper)   r*   c                  s–   t ƒ  |¡ || _|| _|| _t|ƒr@tttt	t
 | d¡d�ƒ| _tttt	t
 | d¡d�ƒ| _tttt
| d¡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   r"   r#   r.   C   s   
zAPIError.__init__)r'   r(   r8   r7   r:   r9   r)   r*   )r   r    r!   r4   r;   r<   r.   r5   r"   r"   r0   r#   r6   0   s   
 
r6   c                      s6   e Zd ZU ded< ded< ddœd‡ fdd„Z‡  ZS )ÚAPIResponseValidationErrorúhttpx.Responser&   ÚintÚstatus_codeN©r'   r:   r9   r'   ú
str | Noner)   r*   c                  s*   t ƒ j|pd|j|d� || _|j| _d S )Nz1Data returned by API invalid for expected schema.©r:   )r-   r.   r8   r&   rD   )r/   r&   r:   r'   r0   r"   r#   r.   W   s   z#APIResponseValidationError.__init__)r&   rB   r:   r9   r'   rF   r)   r*   r3   r"   r"   r0   r#   rA   S   s   
 rA   c                      s<   e Zd ZU dZded< ded< ded< d‡ fdd„Z‡  ZS )ÚAPIStatusErrorz<Raised when an API response has a status code of 4xx or 5xx.rB   r&   rC   rD   rF   Ú
request_idr'   r(   r:   r9   r)   r*   c                  s4   t ƒ j||j|d� || _|j| _|j d¡| _d S )NrG   zx-request-id)r-   r.   r8   r&   rD   Úheadersr@   rI   )r/   r'   r&   r:   r0   r"   r#   r.   d   s   zAPIStatusError.__init__)r'   r(   r&   rB   r:   r9   r)   r*   ©r   r    r!   Ú__doc__r4   r.   r5   r"   r"   r0   r#   rH   ]   s   
 rH   c                      s$   e Zd Zddœd‡ fd	d
„Z‡  ZS )ÚAPIConnectionErrorzConnection error.rE   r'   r(   r8   r7   r)   r*   c                  s   t ƒ j||d d� d S )NrG   ©r-   r.   )r/   r'   r8   r0   r"   r#   r.   l   s   zAPIConnectionError.__init__)r'   r(   r8   r7   r)   r*   ©r   r    r!   r.   r5   r"   r"   r0   r#   rM   k   s    rM   c                      s   e Zd Zd‡ fdd„Z‡  ZS )ÚAPITimeoutErrorr8   r7   r)   r*   c                   s   t ƒ jd|d� d S )NzRequest timed out.)r'   r8   rN   )r/   r8   r0   r"   r#   r.   q   s   zAPITimeoutError.__init__)r8   r7   r)   r*   rO   r"   r"   r0   r#   rP   p   ó    rP   c                   @  ó   e Zd ZU dZded< dS )r   i�  zLiteral[400]rD   N©r   r    r!   rD   r4   r"   r"   r"   r#   r   u   ó   
 r   c                   @  rR   )r   i‘  zLiteral[401]rD   NrS   r"   r"   r"   r#   r   y   rT   r   c                      s(   e Zd ZU ded< d‡ fd	d
„Z‡  ZS )r   zOptional[OAuthErrorCode]Úerrorr&   rB   r:   r9   r)   r*   c                  s\   d}d }t |ƒr| d¡}| d¡}|rt|tƒr|}tƒ j|||d� ttt |ƒ| _	d S )NzOAuth authentication error.rU   Úerror_description)r&   r:   )
r	   r@   Ú
isinstancer(   r-   r.   r   r   r   rU   )r/   r&   r:   r'   rU   Údescriptionr0   r"   r#   r.   €   s   

zOAuthError.__init__)r&   rB   r:   r9   r)   r*   r3   r"   r"   r0   r#   r   }   s   
 r   c                   @  rR   )r   i“  zLiteral[403]rD   NrS   r"   r"   r"   r#   r   Ž   rT   r   c                   @  rR   )r   i”  zLiteral[404]rD   NrS   r"   r"   r"   r#   r   ’   rT   r   c                   @  rR   )r   i™  zLiteral[409]rD   NrS   r"   r"   r"   r#   r   –   rT   r   c                   @  rR   )r   i¦  zLiteral[422]rD   NrS   r"   r"   r"   r#   r   š   rT   r   c                   @  rR   )r   i­  zLiteral[429]rD   NrS   r"   r"   r"   r#   r   ž   rT   r   c                   @  r   )r   Nr   r"   r"   r"   r#   r   ¢   r$   r   c                      s*   e Zd ZU ded< 	 d‡ fdd„Z‡  ZS )r   r   Ú
completionr)   r*   c                  s0   d}|j r|d|j › �7 }tƒ  |¡ || _d S )Nz@Could not parse response content as the length limit was reachedz - )Úusager-   r.   rY   )r/   rY   Úmsgr0   r"   r#   r.   ®   s
   
z LengthFinishReasonError.__init__)rY   r   r)   r*   r3   r"   r"   r0   r#   r   ¦   s   
 r   c                      s   e Zd Zd‡ fdd„Z‡  ZS )r   r)   r*   c                   s   t ƒ  d¡ d S )NzRCould not parse response content as the request was rejected by the content filterrN   )r/   r0   r"   r#   r.   ¸   s   ÿz'ContentFilterFinishReasonError.__init__)r)   r*   rO   r"   r"   r0   r#   r   ·   rQ   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!   rL   r"   r"   r"   r#   r   ¾   s    r   c                      s,   e Zd ZU dZded< d
‡ fdd	„Z‡  ZS )r   z?Raised when a WebSocket connection closes with unsent messages.ú	list[str]Úunsent_messagesr'   r(   r)   r*   c                  r+   r,   )r-   r.   r_   )r/   r'   r_   r0   r"   r#   r.   Ç   r2   z'WebSocketConnectionClosedError.__init__)r'   r(   r_   r^   r)   r*   rK   r"   r"   r0   r#   r   Â   s   
 r   c                   @  r\   )r   zMRaised when the outgoing WebSocket message queue exceeds its byte-size limit.Nr]   r"   r"   r"   r#   r   Ì   s    r   )*Ú
__future__r   Útypingr   r   r   r   Útyping_extensionsr   ÚhttpxÚ_utilsr	   Ú_modelsr
   Útypes.shared.oauth_error_coder   Ú
types.chatr   Ú__all__Ú	Exceptionr   r   r6   rA   rH   rM   rP   r   r   r   r   r   r   r   r   r   r   r   Ú
ValueErrorr   r   r   r"   r"   r"   r#   Ú<module>   s>   #

