(exc: Exception)
| 150 | "your_nscale" in normalized |
| 151 | or normalized.endswith("-here") |
| 152 | or "service_token" in normalized |
| 153 | or "api_key" in normalized |
| 154 | ) |
| 155 | |
| 156 | |
| 157 | def _looks_like_hf_user_token(api_key: Optional[str]) -> bool: |
| 158 | return str(api_key or "").strip().lower().startswith("hf_") |
| 159 | |
| 160 | |
| 161 | def _looks_like_auth_error(exc: Exception) -> bool: |
| 162 | message = str(exc or "").lower() |
| 163 | return any( |
| 164 | token in message |
| 165 | for token in ( |
| 166 | "401", |
| 167 | "unauthorized", |
| 168 | "invalid api key", |