Spaces:
Runtime error
Runtime error
Download interfaces/api/dependencies.py from Ysfxjo/arabic-complaint-classification: direct link, hf CLI and curl.
- Browser
- Download file 501 Bytes
-
https://huggingface.co/spaces/Ysfxjo/arabic-complaint-classification/resolve/main/interfaces/api/dependencies.py
- Command line
-
hf download hf://spaces/Ysfxjo/arabic-complaint-classification/interfaces/api/dependencies.py
-
curl -L -o dependencies.py https://huggingface.co/spaces/Ysfxjo/arabic-complaint-classification/resolve/main/interfaces/api/dependencies.py
501 Bytes
| from fastapi import HTTPException, Request | |
| def get_model_loader(request: Request): | |
| """Returns the loaded ModelLoader or 503 if models failed to load (e.g. missing HF_TOKEN).""" | |
| loader = getattr(request.app.state, "model_loader", None) | |
| if loader is None or not loader.is_ready(): | |
| raise HTTPException(status_code=503, detail={ | |
| "error_code": "MODELS_NOT_READY", | |
| "message": "Models are not loaded or failed to load" | |
| }) | |
| else: | |
| return loader | |