o
    @Bi                     @  sX  d dl mZ d dl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 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dS ))    )annotations)AnyOptionalcast)LiteralN   )is_dict)construct_type)
BadRequestErrorAuthenticationErrorPermissionDeniedErrorNotFoundErrorConflictErrorUnprocessableEntityErrorRateLimitErrorInternalServerErrorLengthFinishReasonErrorContentFilterFinishReasonErrorc                   @     e Zd ZdS )OpenAIErrorN__name__
__module____qualname__ r   r   R/var/www/html/Trade-python/venv/lib/python3.10/site-packages/openai/_exceptions.pyr          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 )APIErrorstrmessagehttpx.Requestrequestobject | NonebodyNzOptional[str]codeparamtypereturnNonec                  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&   )super__init__r!   r   r#   r   r   r   r	   r   r   getr$   r%   r&   )selfr   r!   r#   	__class__r   r   r,   2   s   
zAPIError.__init__)r   r   r!   r    r#   r"   r'   r(   )r   r   r   __annotations__r$   r%   r,   __classcell__r   r   r/   r   r      s   
 
r   c                      s6   e Zd ZU ded< ded< ddd fddZ  ZS )APIResponseValidationErrorhttpx.Responseresponseintstatus_codeNr   r#   r"   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,   r!   r5   r7   )r.   r5   r#   r   r/   r   r   r,   F   s   z#APIResponseValidationError.__init__)r5   r4   r#   r"   r   r9   r'   r(   )r   r   r   r1   r,   r2   r   r   r/   r   r3   B   s   
 r3   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.r4   r5   r6   r7   r9   
request_idr   r   r#   r"   r'   r(   c                  s4   t  j||j|d || _|j| _|jd| _d S )Nr:   zx-request-id)r+   r,   r!   r5   r7   headersr-   r<   )r.   r   r5   r#   r/   r   r   r,   S   s   zAPIStatusError.__init__)r   r   r5   r4   r#   r"   r'   r(   )r   r   r   __doc__r1   r,   r2   r   r   r/   r   r;   L   s   
 r;   c                      s$   e Zd Zddd fd	d
Z  ZS )APIConnectionErrorzConnection error.r8   r   r   r!   r    r'   r(   c                  s   t  j||d d d S )Nr:   r+   r,   )r.   r   r!   r/   r   r   r,   [   s   zAPIConnectionError.__init__)r   r   r!   r    r'   r(   r   r   r   r,   r2   r   r   r/   r   r?   Z   s    r?   c                      s   e Zd Zd fddZ  ZS )APITimeoutErrorr!   r    r'   r(   c                   s   t  jd|d d S )NzRequest timed out.)r   r!   r@   )r.   r!   r/   r   r   r,   `   s   zAPITimeoutError.__init__)r!   r    r'   r(   rA   r   r   r/   r   rB   _       rB   c                   @     e Zd ZU dZded< dS )r
   i  zLiteral[400]r7   Nr   r   r   r7   r1   r   r   r   r   r
   d      
 r
   c                   @  rD   )r   i  zLiteral[401]r7   NrE   r   r   r   r   r   h   rF   r   c                   @  rD   )r   i  zLiteral[403]r7   NrE   r   r   r   r   r   l   rF   r   c                   @  rD   )r   i  zLiteral[404]r7   NrE   r   r   r   r   r   p   rF   r   c                   @  rD   )r   i  zLiteral[409]r7   NrE   r   r   r   r   r   t   rF   r   c                   @  rD   )r   i  zLiteral[422]r7   NrE   r   r   r   r   r   x   rF   r   c                   @  rD   )r   i  zLiteral[429]r7   NrE   r   r   r   r   r   |   rF   r   c                   @  r   )r   Nr   r   r   r   r   r      r   r   c                         e Zd Zd fddZ  ZS )r   r'   r(   c                      t  d d S )Nz@Could not parse response content as the length limit was reachedr@   r.   r/   r   r   r,         z LengthFinishReasonError.__init__r'   r(   rA   r   r   r/   r   r      rC   r   c                      rG   )r   r'   r(   c                   rH   )NzRCould not parse response content as the request was rejected by the content filterr@   rI   r/   r   r   r,      rJ   z'ContentFilterFinishReasonError.__init__rK   rA   r   r   r/   r   r      rC   r   )
__future__r   typingr   r   r   typing_extensionsr   httpx_utilsr   _modelsr	   __all__	Exceptionr   r   r3   r;   r?   rB   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s.   #
