Spaces:
Running
on
Zero
Running
on
Zero
| import os | |
| def _install_hf_folder_shim() -> None: | |
| try: | |
| import huggingface_hub | |
| except Exception: | |
| return | |
| if hasattr(huggingface_hub, "HfFolder"): | |
| return | |
| class HfFolder: | |
| def get_token() -> str | None: | |
| return os.getenv("HUGGINGFACE_HUB_TOKEN") or os.getenv("HF_TOKEN") | |
| def save_token(token: str) -> None: | |
| os.environ["HUGGINGFACE_HUB_TOKEN"] = token | |
| def delete_token() -> None: | |
| os.environ.pop("HUGGINGFACE_HUB_TOKEN", None) | |
| huggingface_hub.HfFolder = HfFolder | |
| _install_hf_folder_shim() | |