()
| 58 | } |
| 59 | |
| 60 | |
| 61 | def huggingface_token() -> str | None: |
| 62 | token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGING_FACE_HUB_TOKEN") |
| 63 | if token: |
| 64 | return token.strip() |
| 65 | token_path = Path.home() / ".cache" / "huggingface" / "token" |
| 66 | if token_path.is_file(): |
| 67 | cached = token_path.read_text(encoding="utf-8").strip() |
| 68 | if cached: |
| 69 | return cached |
| 70 | return None |
| 71 | |
| 72 |
no test coverage detected