feat: add HuggingFace mirror support for VM providers (#278)

Add support for HuggingFace mirror (hf-mirror.com) to improve download
speeds in regions where huggingface.co access is slow.

- Support HF_ENDPOINT environment variable detection
- Automatically switch to hf-mirror.com when HF_ENDPOINT is set
- Apply to Docker, VMware, and VirtualBox providers
- Maintain backward compatibility with default huggingface.co URLs

Users can now set HF_ENDPOINT=https://hf-mirror.com to use the mirror.
This commit is contained in:
张逸群
2025-07-23 03:40:35 +08:00
committed by GitHub
parent 0a37cccd53
commit 4a5d48000f
3 changed files with 26 additions and 0 deletions

View File

@@ -134,6 +134,13 @@ def _install_vm(vm_name, vms_dir, downloaded_file_name, os_type, original_vm_nam
elif os_type == "Windows":
if platform.machine().lower() in ['amd64', 'x86_64']:
URL = WINDOWS_X86_URL
# Check for HF_ENDPOINT environment variable and replace domain if set to hf-mirror.com
hf_endpoint = os.environ.get('HF_ENDPOINT')
if hf_endpoint and 'hf-mirror.com' in hf_endpoint:
URL = URL.replace('huggingface.co', 'hf-mirror.com')
logger.info(f"Using HF mirror: {URL}")
DOWNLOADED_FILE_NAME = URL.split('/')[-1]
downloaded_file_name = DOWNLOADED_FILE_NAME