o
    ni+                     @  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'dS )1    )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SubjectTokenProviderErrorc                   @     e Zd ZdS )OpenAIErrorN__name__
__module____qualname__ r    r    R/var/www/html/arapca_proje/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                  s   t  | || _d S )N)super__init__r$   )selfr%   r$   	__class__r    r!   r*   )   s   
z"SubjectTokenProviderError.__init__)r%   r&   r$   r#   r'   r(   r   r   r   __annotations__r*   __classcell__r    r    r,   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 )Nr6   )type_valuer7   r8   )r)   r*   r3   r%   r5   r	   r   r   r
   r   r&   getr6   r7   r8   )r+   r%   r3   r5   r,   r    r!   r*   A   s   
zAPIError.__init__)r%   r&   r3   r2   r5   r4   r'   r(   )r   r   r   r/   r6   r7   r*   r0   r    r    r,   r!   r1   .   s   
 
r1   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%   r5   r4   r%   
str | Noner'   r(   c                  s*   t  j|pd|j|d || _|j| _d S )Nz1Data returned by API invalid for expected schema.r5   )r)   r*   r3   r$   r?   )r+   r$   r5   r%   r,   r    r!   r*   U   s   z#APIResponseValidationError.__init__)r$   r=   r5   r4   r%   rA   r'   r(   r.   r    r    r,   r!   r<   Q   s   
 r<   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.r=   r$   r>   r?   rA   
request_idr%   r&   r5   r4   r'   r(   c                  s4   t  j||j|d || _|j| _|jd| _d S )NrB   zx-request-id)r)   r*   r3   r$   r?   headersr;   rD   )r+   r%   r$   r5   r,   r    r!   r*   b   s   zAPIStatusError.__init__)r%   r&   r$   r=   r5   r4   r'   r(   )r   r   r   __doc__r/   r*   r0   r    r    r,   r!   rC   [   s   
 rC   c                      s$   e Zd Zddd fd	d
Z  ZS )APIConnectionErrorzConnection error.r@   r%   r&   r3   r2   r'   r(   c                  s   t  j||d d d S )NrB   r)   r*   )r+   r%   r3   r,   r    r!   r*   j   s   zAPIConnectionError.__init__)r%   r&   r3   r2   r'   r(   r   r   r   r*   r0   r    r    r,   r!   rG   i   s    rG   c                      s   e Zd Zd fddZ  ZS )APITimeoutErrorr3   r2   r'   r(   c                   s   t  jd|d d S )NzRequest timed out.)r%   r3   rH   )r+   r3   r,   r    r!   r*   o   s   zAPITimeoutError.__init__)r3   r2   r'   r(   rI   r    r    r,   r!   rJ   n       rJ   c                   @     e Zd ZU dZded< dS )r   i  zLiteral[400]r?   Nr   r   r   r?   r/   r    r    r    r!   r   s      
 r   c                   @  rL   )r   i  zLiteral[401]r?   NrM   r    r    r    r!   r   w   rN   r   c                      s(   e Zd ZU ded< d fd	d
Z  ZS )r   zOptional[OAuthErrorCode]errorr$   r=   r5   r4   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.rO   error_description)r$   r5   )
r	   r;   
isinstancer&   r)   r*   r   r   r   rO   )r+   r$   r5   r%   rO   descriptionr,   r    r!   r*   ~   s   

zOAuthError.__init__)r$   r=   r5   r4   r'   r(   r.   r    r    r,   r!   r   {   s   
 r   c                   @  rL   )r   i  zLiteral[403]r?   NrM   r    r    r    r!   r      rN   r   c                   @  rL   )r   i  zLiteral[404]r?   NrM   r    r    r    r!   r      rN   r   c                   @  rL   )r   i  zLiteral[409]r?   NrM   r    r    r    r!   r      rN   r   c                   @  rL   )r   i  zLiteral[422]r?   NrM   r    r    r    r!   r      rN   r   c                   @  rL   )r   i  zLiteral[429]r?   NrM   r    r    r    r!   r      rN   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*   rS   )r+   rS   msgr,   r    r!   r*      s
   
z LengthFinishReasonError.__init__)rS   r   r'   r(   r.   r    r    r,   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 filterrH   )r+   r,   r    r!   r*      s   z'ContentFilterFinishReasonError.__init__)r'   r(   rI   r    r    r,   r!   r      rK   r   c                   @  s   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   rF   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   r1   r<   rC   rG   rJ   r   r   r   r   r   r   r   r   r   r   r   
ValueErrorr   r    r    r    r!   <module>   s:   #
