HF_AGENT / patch_gradio.py
Brettapps's picture
Syncing files from local MCP agent storage
4745480 verified
Raw
History Blame Contribute Delete
523 Bytes
import os
oauth_file = "/usr/local/lib/python3.12/site-packages/gradio/oauth.py"
with open(oauth_file, 'r') as f:
content = f.read()
# Replace the problematic import
patch = """
try:
from huggingface_hub import HfFolder, whoami
except ImportError:
class HfFolder:
@staticmethod
def get_token(): return None
def whoami(): return {}
"""
new_content = content.replace("from huggingface_hub import HfFolder, whoami", patch.strip())
with open(oauth_file, 'w') as f:
f.write(new_content)