Download networks/exceptions.py from AIMaster7/HFLLMAPI2: direct link, hf CLI and curl.
- Browser
- Download file 750 Bytes
-
https://huggingface.co/spaces/AIMaster7/HFLLMAPI2/resolve/main/networks/exceptions.py
- Command line
-
hf download hf://spaces/AIMaster7/HFLLMAPI2/networks/exceptions.py
-
curl -L -o exceptions.py https://huggingface.co/spaces/AIMaster7/HFLLMAPI2/resolve/main/networks/exceptions.py
750 Bytes
| import http | |
| from typing import Optional | |
| from fastapi import HTTPException, status | |
| class HfApiException(Exception): | |
| def __init__( | |
| self, | |
| status_code: int, | |
| detail: Optional[str] = None, | |
| ) -> None: | |
| if detail is None: | |
| self.detail = http.HTTPStatus(status_code).phrase | |
| else: | |
| self.detail = detail | |
| self.status_code = status_code | |
| def __repr__(self) -> str: | |
| class_name = self.__class__.__name__ | |
| return f"{class_name}(status_code={self.status_code!r}, detail={self.detail!r})" | |
| def __str__(self) -> str: | |
| return self.__repr__() | |
| INVALID_API_KEY_ERROR = HfApiException( | |
| status_code=status.HTTP_403_FORBIDDEN, | |
| detail="Invalid API Key", | |
| ) | |