
    o i-                        d Z ddlmZ ddlmZmZ ddlmZm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e          Z G d dee          Z G d de	          Z G d de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/ d0e          Z$ G d1 d2e          Z% G d3 d4e	          Z& G d5 d6ee&          Z' G d7 d8e(e&          Z) G d9 d:ee          Z* G d; d<e	          Z+ G d= d>e+          Z, G d? d@e+          Z- G dA dBe-          Z. G dC dDe	          Z/ G dE dFe/          Z0 G dG dHe/          Z1 G dI dJe/          Z2 G dK dLe	          Z3 G dM dNe3          Z4 G dO dPe3          Z5 G dQ dRe	          Z6dSS )TzContains all custom errors.    )Path)OptionalUnion)	HTTPErrorResponsec                   X     e Zd ZU dZeeef         ed<   dedeeef         f fdZ xZ	S )CacheNotFoundz9Exception thrown when the Huggingface cache is not found.	cache_dirmsgc                 P     t                      j        |g|R i | || _        d S N)super__init__r
   )selfr   r
   argskwargs	__class__s        V/var/www/html/auto_sub_bot/venv/lib/python3.11/site-packages/huggingface_hub/errors.pyr   zCacheNotFound.__init__   s5    .t...v..."    )
__name__
__module____qualname____doc__r   strr   __annotations__r   __classcell__r   s   @r   r	   r	      sq         CCS$Y#C #E#t),< # # # # # # # # # #r   r	   c                       e Zd ZdZdS )CorruptedCacheExceptionzGException for any unexpected structure in the Huggingface cache-system.Nr   r   r   r    r   r   r   r      s        QQQQr   r   c                       e Zd ZdZdS )LocalTokenNotFoundErrorz0Raised if local token is required but not found.Nr    r!   r   r   r#   r#              ::::r   r#   c                       e Zd ZdZdS )OfflineModeIsEnabledzTRaised when a request is made but `HF_HUB_OFFLINE=1` is set as environment variable.Nr    r!   r   r   r&   r&   $   s        ^^^^r   r&   c                   X     e Zd ZdZdddededee         f fdZded	dfd
Zd Z	 xZ
S )HfHubHTTPErrora=  
    HTTPError to inherit from for any custom HTTP Error raised in HF Hub.

    Any HTTPError is converted at least into a `HfHubHTTPError`. If some information is
    sent back by the server, it will be added to the error message.

    Added details:
    - Request id from "X-Request-Id" header if exists. If not, fallback to "X-Amzn-Trace-Id" header if exists.
    - Server error message from the header "X-Error-Message".
    - Server error message if we can found one in the response body.

    Example:
    ```py
        import httpx
        from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError

        response = get_session().post(...)
        try:
            hf_raise_for_status(response)
        except HfHubHTTPError as e:
            print(str(e)) # formatted message
            e.request_id, e.server_message # details returned by server

            # Complete the error message with additional information once it's raised
            e.append_to_message("
`create_commit` expects the repository to exist.")
            raise
    ```
    N)server_messagemessageresponser)   c                    |j                             d          p|j                             d          | _        || _        || _        |j        | _        t                                          |           d S )Nzx-request-idzX-Amzn-Trace-Id)headersget
request_idr)   r+   requestr   r   )r   r*   r+   r)   r   s       r   r   zHfHubHTTPError.__init__F   sk     #*..~>>i(BRBVBVWhBiBi, '!!!!!r   additional_messagereturnc                 R    | j         d         |z   f| j         dd         z   | _         dS )zFAppend additional information to the `HfHubHTTPError` initial message.r      N)r   )r   r1   s     r   append_to_messagez HfHubHTTPError.append_to_messageS   s+    Yq\$66849QRR=H			r   c                 L    | j         t          |           f| j        | j        dfS )zeFix pickling of Exception subclass with kwargs. We need to override __reduce_ex__ of the parent class)r+   r)   )r   r   r+   r)   )r   protocols     r   __reduce_ex__zHfHubHTTPError.__reduce_ex__W   s'    T4=\`\o.p.pqqr   )r   r   r   r   r   r   r   r   r5   r8   r   r   s   @r   r(   r(   (   s         D )-" " "" 	"
 !" " " " " "IC ID I I I Ir r r r r r rr   r(   c                       e Zd ZdZdS )InferenceTimeoutErrorzBError raised when a model is unavailable or the request times out.Nr    r!   r   r   r:   r:   _   s        LLLLr   r:   c                       e Zd ZdZdS )InferenceEndpointErrorz8Generic exception when dealing with Inference Endpoints.Nr    r!   r   r   r<   r<   f   s        BBBBr   r<   c                       e Zd ZdZdS )InferenceEndpointTimeoutErrorz<Exception for timeouts while waiting for Inference Endpoint.Nr    r!   r   r   r>   r>   j   s        FFFFr   r>   c                       e Zd ZdZdS )SafetensorsParsingErrorzRaised when failing to parse a safetensors file metadata.

    This can be the case if the file is not a safetensors file or does not respect the specification.
    Nr    r!   r   r   r@   r@   q              r   r@   c                       e Zd ZdZdS )NotASafetensorsRepoErrorzRaised when a repo is not a Safetensors repo i.e. doesn't have either a `model.safetensors` or a
    `model.safetensors.index.json` file.
    Nr    r!   r   r   rC   rC   x   s           r   rC   c                       e Zd ZdZdS )TextGenerationErrorz3Generic error raised if text-generation went wrong.Nr    r!   r   r   rE   rE              ====r   rE   c                       e Zd ZdZdS )ValidationErrorzServer-side validation error.Nr    r!   r   r   rH   rH      s        ''''r   rH   c                       e Zd ZdS )GenerationErrorNr   r   r   r!   r   r   rJ   rJ              Dr   rJ   c                       e Zd ZdS )OverloadedErrorNrK   r!   r   r   rN   rN      rL   r   rN   c                       e Zd ZdS )IncompleteGenerationErrorNrK   r!   r   r   rP   rP      rL   r   rP   c                       e Zd ZdS )UnknownErrorNrK   r!   r   r   rR   rR      rL   r   rR   c                       e Zd ZdZdS )HFValidationErrorzGeneric exception thrown by `huggingface_hub` validators.

    Inherits from [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError).
    Nr    r!   r   r   rT   rT      rA   r   rT   c                       e Zd ZdZdS )DryRunErrorzXError triggered when a dry run is requested but cannot be performed (e.g. invalid repo).Nr    r!   r   r   rV   rV              bbbbr   rV   c                       e Zd ZdZdS )FileMetadataErrorzError triggered when the metadata of a file on the Hub cannot be retrieved (missing ETag or commit_hash).

    Inherits from `OSError` for backward compatibility.
    Nr    r!   r   r   rY   rY      rA   r   rY   c                       e Zd ZdZdS )RepositoryNotFoundErrora  
    Raised when trying to access a hf.co URL with an invalid repository name, or
    with a private repo name the user does not have access to.

    Example:

    ```py
    >>> from huggingface_hub import model_info
    >>> model_info("<non_existent_repository>")
    (...)
    huggingface_hub.errors.RepositoryNotFoundError: 401 Client Error. (Request ID: PvMw_VjBMjVdMz53WKIzP)

    Repository Not Found for url: https://huggingface.co/api/models/%3Cnon_existent_repository%3E.
    Please make sure you specified the correct `repo_id` and `repo_type`.
    If the repo is private, make sure you are authenticated.
    Invalid username or password.
    ```
    Nr    r!   r   r   r[   r[      s           r   r[   c                       e Zd ZdZdS )GatedRepoErrora  
    Raised when trying to access a gated repository for which the user is not on the
    authorized list.

    Note: derives from `RepositoryNotFoundError` to ensure backward compatibility.

    Example:

    ```py
    >>> from huggingface_hub import model_info
    >>> model_info("<gated_repository>")
    (...)
    huggingface_hub.errors.GatedRepoError: 403 Client Error. (Request ID: ViT1Bf7O_026LGSQuVqfa)

    Cannot access gated repo for url https://huggingface.co/api/models/ardent-figment/gated-model.
    Access to model ardent-figment/gated-model is restricted and you are not in the authorized list.
    Visit https://huggingface.co/ardent-figment/gated-model to ask for access.
    ```
    Nr    r!   r   r   r]   r]      s           r   r]   c                       e Zd ZdZdS )DisabledRepoErrora  
    Raised when trying to access a repository that has been disabled by its author.

    Example:

    ```py
    >>> from huggingface_hub import dataset_info
    >>> dataset_info("laion/laion-art")
    (...)
    huggingface_hub.errors.DisabledRepoError: 403 Client Error. (Request ID: Root=1-659fc3fa-3031673e0f92c71a2260dbe2;bc6f4dfb-b30a-4862-af0a-5cfe827610d8)

    Cannot access repository for url https://huggingface.co/api/datasets/laion/laion-art.
    Access to this resource is disabled.
    ```
    Nr    r!   r   r   r_   r_                 r   r_   c                       e Zd ZdZdS )RevisionNotFoundErrora  
    Raised when trying to access a hf.co URL with a valid repository but an invalid
    revision.

    Example:

    ```py
    >>> from huggingface_hub import hf_hub_download
    >>> hf_hub_download('bert-base-cased', 'config.json', revision='<non-existent-revision>')
    (...)
    huggingface_hub.errors.RevisionNotFoundError: 404 Client Error. (Request ID: Mwhe_c3Kt650GcdKEFomX)

    Revision Not Found for url: https://huggingface.co/bert-base-cased/resolve/%3Cnon-existent-revision%3E/config.json.
    ```
    Nr    r!   r   r   rb   rb      r`   r   rb   c                       e Zd ZdZdS )EntryNotFoundErrora  
    Raised when entry not found, either locally or remotely.

    Example:

    ```py
    >>> from huggingface_hub import hf_hub_download
    >>> hf_hub_download('bert-base-cased', '<non-existent-file>')
    (...)
    huggingface_hub.errors.RemoteEntryNotFoundError (...)
    >>> hf_hub_download('bert-base-cased', '<non-existent-file>', local_files_only=True)
    (...)
    huggingface_hub.utils.errors.LocalEntryNotFoundError (...)
    ```
    Nr    r!   r   r   rd   rd     r`   r   rd   c                       e Zd ZdZdS )RemoteEntryNotFoundErrora  
    Raised when trying to access a hf.co URL with a valid repository and revision
    but an invalid filename.

    Example:

    ```py
    >>> from huggingface_hub import hf_hub_download
    >>> hf_hub_download('bert-base-cased', '<non-existent-file>')
    (...)
    huggingface_hub.errors.EntryNotFoundError: 404 Client Error. (Request ID: 53pNl6M0MxsnG5Sw8JA6x)

    Entry Not Found for url: https://huggingface.co/bert-base-cased/resolve/main/%3Cnon-existent-file%3E.
    ```
    Nr    r!   r   r   rf   rf     r`   r   rf   c                   (     e Zd ZdZdef fdZ xZS )LocalEntryNotFoundErroraF  
    Raised when trying to access a file or snapshot that is not on the disk when network is
    disabled or unavailable (connection issue). The entry may exist on the Hub.

    Example:

    ```py
    >>> from huggingface_hub import hf_hub_download
    >>> hf_hub_download('bert-base-cased', '<non-cached-file>',  local_files_only=True)
    (...)
    huggingface_hub.errors.LocalEntryNotFoundError: Cannot find the requested files in the disk cache and outgoing traffic has been disabled. To enable hf.co look-ups and downloads online, set 'local_files_only' to False.
    ```
    r*   c                 J    t                                          |           d S r   )r   r   )r   r*   r   s     r   r   z LocalEntryNotFoundError.__init__;  s!    !!!!!r   )r   r   r   r   r   r   r   r   s   @r   rh   rh   ,  sN         " " " " " " " " " " "r   rh   c                       e Zd ZdZdS )BadRequestErroraG  
    Raised by `hf_raise_for_status` when the server returns a HTTP 400 error.

    Example:

    ```py
    >>> resp = httpx.post("hf.co/api/check", ...)
    >>> hf_raise_for_status(resp, endpoint_name="check")
    huggingface_hub.errors.BadRequestError: Bad request for check endpoint: {details} (Request ID: XXX)
    ```
    Nr    r!   r   r   rk   rk   @  s        
 
 
 
r   rk   c                       e Zd ZdZdS )	DDUFErrorz5Base exception for errors related to the DDUF format.Nr    r!   r   r   rm   rm   Q  s        ????r   rm   c                       e Zd ZdZdS )DDUFCorruptedFileErrorz1Exception thrown when the DDUF file is corrupted.Nr    r!   r   r   ro   ro   U          ;;;;r   ro   c                       e Zd ZdZdS )DDUFExportErrorz-Base exception for errors during DDUF export.Nr    r!   r   r   rr   rr   Y  s        7777r   rr   c                       e Zd ZdZdS )DDUFInvalidEntryNameErrorz0Exception thrown when the entry name is invalid.Nr    r!   r   r   rt   rt   ]  r$   r   rt   c                       e Zd ZdZdS )StrictDataclassErrorz&Base exception for strict dataclasses.Nr    r!   r   r   rv   rv   d  s        0000r   rv   c                       e Zd ZdZdS )StrictDataclassDefinitionErrorz@Exception thrown when a strict dataclass is defined incorrectly.Nr    r!   r   r   rx   rx   h  s        JJJJr   rx   c                   ,     e Zd ZdZdedef fdZ xZS )#StrictDataclassFieldValidationErrorzLException thrown when a strict dataclass fails validation for a given field.fieldcausec                     d| d}|d|j         j         d| z  }t                                          |           d S )NzValidation error for field '':
    : r   r   r   r   )r   r{   r|   error_messager   s       r   r   z,StrictDataclassFieldValidationError.__init__o  sQ    @u@@@E%/":EEeEEE'''''r   r   r   r   r   r   	Exceptionr   r   r   s   @r   rz   rz   l  sQ        VV(c () ( ( ( ( ( ( ( ( ( (r   rz   c                   ,     e Zd ZdZdedef fdZ xZS )#StrictDataclassClassValidationErrorzOException thrown when a strict dataclass fails validation on a class validator.	validatorr|   c                     d| d}|d|j         j         d| z  }t                                          |           d S )Nz&Class validation error for validator 'r~   r   r   r   )r   r   r|   r   r   s       r   r   z,StrictDataclassClassValidationError.__init__x  sQ    NNNNE%/":EEeEEE'''''r   r   r   s   @r   r   r   u  sQ        YY(# (i ( ( ( ( ( ( ( ( ( (r   r   c                       e Zd ZdZdS )XetErrorz1Base exception for errors related to Xet Storage.Nr    r!   r   r   r   r     rp   r   r   c                       e Zd ZdZdS )XetAuthorizationErrorzXException thrown when the user does not have the right authorization to use Xet Storage.Nr    r!   r   r   r   r     rW   r   r   c                       e Zd ZdZdS )XetRefreshTokenErrorz3Exception thrown when the refresh token is invalid.Nr    r!   r   r   r   r     rF   r   r   c                       e Zd ZdZdS )XetDownloadErrorz:Exception thrown when the download from Xet Storage fails.Nr    r!   r   r   r   r     s        DDDDr   r   N)7r   pathlibr   typingr   r   httpxr   r   r   r	   r   EnvironmentErrorr#   ConnectionErrorr&   OSErrorr(   TimeoutErrorr:   r<   r>   r@   rC   rE   rH   rJ   rN   rP   rR   
ValueErrorrT   rV   rY   r[   r]   r_   rb   rd   rf   FileNotFoundErrorrh   rk   rm   ro   rr   rt   rv   rx   rz   r   r   r   r   r   r!   r   r   <module>r      s2   ! !       " " " " " " " " % % % % % % % %# # # # #I # # #R R R R Ri R R R; ; ; ; ;. ; ; ;_ _ _ _ _? _ _ _1r 1r 1r 1r 1rY 1r 1r 1rnM M M M MI| M M MC C C C CY C C CG G G G G$:L G G G    i       y   > > > > >) > > >
( ( ( ( () ( ( (	 	 	 	 	) 	 	 		 	 	 	 	) 	 	 		 	 	 	 	 3 	 	 		 	 	 	 	& 	 	 	    
   c c c c c' c c c           n   *    ,   ,       *    N   &       $    ~/A   $" " " " "/1C " " "(    nj   "@ @ @ @ @	 @ @ @< < < < <Y < < <8 8 8 8 8i 8 8 8; ; ; ; ; ; ; ;1 1 1 1 19 1 1 1K K K K K%9 K K K( ( ( ( (*> ( ( (( ( ( ( (*> ( ( (< < < < <y < < <c c c c cH c c c> > > > >8 > > >E E E E Ey E E E E Er   