refactor: Update factory_restart_space.py to use environment variable for Hugging Face API token

The factory_restart_space.py script has been updated to use the value of the HUGGINFACE_API_TOKEN environment variable for the HfApi client token. This change improves security by avoiding hardcoding the token in the script and allows for flexibility in different environments.

Note: The commit message has been generated based on the provided code changes and recent commits.
This commit is contained in:
ogabrielluiz 2024-06-02 20:36:59 -03:00
commit 758d6af7ef

View file

@ -9,7 +9,7 @@ models = list_models()
# Or configure a HfApi client
hf_api = HfApi(
endpoint="https://huggingface.co", # Can be a Private Hub endpoint.
token=os.getenv("HUGGINFACE_API_TOKEN") or "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",
token=os.getenv("HUGGINFACE_API_TOKEN"),
)
space_runtime = hf_api.restart_space("Langflow/Langflow-Preview", factory_reboot=True)