Spaces:
Sleeping
Sleeping
File size: 659 Bytes
cf4c436 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import os
def _install_hf_folder_shim() -> None:
try:
import huggingface_hub
except Exception:
return
if hasattr(huggingface_hub, "HfFolder"):
return
class HfFolder:
@staticmethod
def get_token() -> str | None:
return os.getenv("HUGGINGFACE_HUB_TOKEN") or os.getenv("HF_TOKEN")
@staticmethod
def save_token(token: str) -> None:
os.environ["HUGGINGFACE_HUB_TOKEN"] = token
@staticmethod
def delete_token() -> None:
os.environ.pop("HUGGINGFACE_HUB_TOKEN", None)
huggingface_hub.HfFolder = HfFolder
_install_hf_folder_shim()
|