o
    "ch                     @  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 er0d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#dS ),    )annotations)TYPE_CHECKINGAnyOptionalcast)LiteralN   )is_dict)construct_type)ChatCompletion)BadRequestErrorAuthenticationErrorPermissionDeniedErrorNotFoundErrorConflictErrorUnprocessableEntityErrorRateLimitErrorInternalServerErrorLengthFinishReasonErrorContentFilterFinishReasonErrorInvalidWebhookSignatureErrorc                   @     e Zd ZdS )OpenAIErrorN__name__
__module____qualname__ r   r   P/home/air/goalskill/back/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/   6   s   
zAPIError.__init__)r"   r!   r$   r#   r&   r%   r*   r+   )r   r   r   __annotations__r'   r(   r/   __classcell__r   r   r2   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$   r8   r:   )r1   r8   r&   r"   r2   r   r   r/   J   s   z#APIResponseValidationError.__init__)r8   r7   r&   r%   r"   r<   r*   r+   r   r   r   r4   r/   r5   r   r   r2   r   r6   F   s   
 r6   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.r7   r8   r9   r:   r<   
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$   r8   r:   headersr0   r@   )r1   r"   r8   r&   r2   r   r   r/   W   s   zAPIStatusError.__init__)r"   r!   r8   r7   r&   r%   r*   r+   )r   r   r   __doc__r4   r/   r5   r   r   r2   r   r?   P   s   
 r?   c                      s$   e Zd Zddd fd	d
Z  ZS )APIConnectionErrorzConnection error.r;   r"   r!   r$   r#   r*   r+   c                  s   t  j||d d d S )Nr=   r.   r/   )r1   r"   r$   r2   r   r   r/   _   s   zAPIConnectionError.__init__)r"   r!   r$   r#   r*   r+   r   r   r   r/   r5   r   r   r2   r   rC   ^   s    rC   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$   rD   )r1   r$   r2   r   r   r/   d   s   zAPITimeoutError.__init__)r$   r#   r*   r+   rE   r   r   r2   r   rF   c       rF   c                   @     e Zd ZU dZded< dS )r   i  zLiteral[400]r:   Nr   r   r   r:   r4   r   r   r   r   r   h      
 r   c                   @  rH   )r   i  zLiteral[401]r:   NrI   r   r   r   r   r   l   rJ   r   c                   @  rH   )r   i  zLiteral[403]r:   NrI   r   r   r   r   r   p   rJ   r   c                   @  rH   )r   i  zLiteral[404]r:   NrI   r   r   r   r   r   t   rJ   r   c                   @  rH   )r   i  zLiteral[409]r:   NrI   r   r   r   r   r   x   rJ   r   c                   @  rH   )r   i  zLiteral[422]r:   NrI   r   r   r   r   r   |   rJ   r   c                   @  rH   )r   i  zLiteral[429]r:   NrI   r   r   r   r   r      rJ   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/   rK   )r1   rK   msgr2   r   r   r/      s
   
z LengthFinishReasonError.__init__)rK   r   r*   r+   r>   r   r   r2   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 filterrD   )r1   r2   r   r   r/      s   z'ContentFilterFinishReasonError.__init__)r*   r+   rE   r   r   r2   r   r      rG   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   rB   r   r   r   r   r      s    r   )$
__future__r   typingr   r   r   r   typing_extensionsr   httpx_utilsr	   _modelsr
   
types.chatr   __all__	Exceptionr   r    r6   r?   rC   rF   r   r   r   r   r   r   r   r   r   r   
ValueErrorr   r   r   r   r   <module>   s4   #
