|
"""Contains all custom errors.""" |
|
|
|
from requests import HTTPError |
|
|
|
|
|
|
|
|
|
|
|
class LocalTokenNotFoundError(EnvironmentError): |
|
"""Raised if local token is required but not found.""" |
|
|
|
|
|
|
|
|
|
|
|
class OfflineModeIsEnabled(ConnectionError): |
|
"""Raised when a request is made but `HF_HUB_OFFLINE=1` is set as environment variable.""" |
|
|
|
|
|
|
|
|
|
|
|
class InferenceTimeoutError(HTTPError, TimeoutError): |
|
"""Error raised when a model is unavailable or the request times out.""" |
|
|
|
|
|
|
|
|
|
|
|
class InferenceEndpointError(Exception): |
|
"""Generic exception when dealing with Inference Endpoints.""" |
|
|
|
|
|
class InferenceEndpointTimeoutError(InferenceEndpointError, TimeoutError): |
|
"""Exception for timeouts while waiting for Inference Endpoint.""" |
|
|
|
|
|
|
|
|
|
|
|
class SafetensorsParsingError(Exception): |
|
"""Raised 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. |
|
""" |
|
|
|
|
|
class NotASafetensorsRepoError(Exception): |
|
"""Raised when a repo is not a Safetensors repo i.e. doesn't have either a `model.safetensors` or a |
|
`model.safetensors.index.json` file. |
|
""" |
|
|
|
|
|
|
|
|
|
|
|
class TemplateError(Exception): |
|
"""Any error raised while trying to fetch or render a chat template.""" |
|
|
|
|
|
|
|
|
|
|
|
class TextGenerationError(HTTPError): |
|
"""Generic error raised if text-generation went wrong.""" |
|
|
|
|
|
|
|
class ValidationError(TextGenerationError): |
|
"""Server-side validation error.""" |
|
|
|
|
|
class GenerationError(TextGenerationError): |
|
pass |
|
|
|
|
|
class OverloadedError(TextGenerationError): |
|
pass |
|
|
|
|
|
class IncompleteGenerationError(TextGenerationError): |
|
pass |
|
|
|
|
|
class UnknownError(TextGenerationError): |
|
pass |
|
|
|
|
|
|
|
|
|
|
|
class HFValidationError(ValueError): |
|
"""Generic exception thrown by `huggingface_hub` validators. |
|
|
|
Inherits from [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError). |
|
""" |
|
|