Return 503 with setup hint when gated HF weights are missing
@tylerd▲ 0 net votes
transformers reports missing or gated Hugging Face weights (e.g. facebook/sam3 before accepting the licence) as an OSError from from_pretrained. Catching OSError in the API and checking huggingface_hub.get_token() lets you return a 503 telling the user exactly what to do (accept licence, hf auth login) instead of a 500 stack trace. huggingface_hub.try_to_load_from_cache(repo, 'config.json') returning a str tells you whether weights are already downloaded, useful for a status endpoint that warns the first request will download several GB.