# How to Upload app.py to HuggingFace Spaces ## ✅ Good News: app.py is Already Fixed! Your local `app.py` file is correctly configured with: - ✅ `USE_HF_API = "True"` (line 143) - ✅ `USE_LMSTUDIO = "False"` (line 144) - ✅ `LLM_BACKEND = "hf_api"` (line 145) - ✅ `LLM_TIMEOUT = "180"` (line 147) **Location**: `/home/john/TranscriptorEnhanced/app.py` **File size**: 44KB **Last modified**: Oct 30, 18:04 --- ## 🚀 How to Upload to Your HuggingFace Space ### **Method 1: Via HuggingFace Web Interface (Easiest)** 1. **Open your Space in browser** - Go to: https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE 2. **Click "Files" tab** 3. **Click on "app.py"** to open it 4. **Click the "Edit" button** (pencil icon) 5. **Delete ALL content** in the editor (Ctrl+A, Delete) 6. **Open your local file**: ```bash # On your local machine, open: /home/john/TranscriptorEnhanced/app.py ``` 7. **Copy ALL content** from your local file (Ctrl+A, Ctrl+C) 8. **Paste into HF editor** (Ctrl+V) 9. **Click "Commit changes to main"** 10. **Wait 2-3 minutes** for Space to rebuild --- ### **Method 2: Via Git (If You Have Git Access)** If you cloned your Space repository: ```bash # Navigate to your Space repo cd /path/to/your-space-repo # Copy the fixed file cp /home/john/TranscriptorEnhanced/app.py . # Commit and push git add app.py git commit -m "Fix: Force HF API mode to resolve timeout errors" git push ``` --- ### **Method 3: Direct File Upload** 1. **Go to your Space**: https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE 2. **Click "Files" tab** 3. **Click "Upload files"** button 4. **Select your local file**: ``` /home/john/TranscriptorEnhanced/app.py ``` 5. **Choose**: "Overwrite existing file" 6. **Click "Commit"** --- ## ✅ Verification After Upload ### **Step 1: Check the Logs** After your Space restarts, click the **"Logs"** tab and look for: ``` 🚀 Forcing HF API mode for HuggingFace Spaces deployment... ✅ HuggingFace token detected ✅ Configuration loaded for HuggingFace Spaces 🚀 TranscriptorAI Enterprise - LLM Backend: hf_api 🔧 USE_HF_API: True 🔧 USE_LMSTUDIO: False 🔧 LLM_TIMEOUT: 180s ``` **Good signs**: - ✅ "Forcing HF API mode" - ✅ "HuggingFace token detected" - ✅ "LLM Backend: hf_api" - ✅ "USE_HF_API: True" **Bad signs** (means old file still there): - ❌ "LLM Backend: local" - ❌ "USE_HF_API: False" - ❌ "Loading local model: microsoft/Phi-3" ### **Step 2: Test Processing** Upload a test transcript and check logs for: ``` INFO: Calling HF API: microsoft/Phi-3-mini-4k-instruct ``` **Should NOT see**: ``` INFO: Generating with local model ERROR: LLM generation timed out ``` ### **Step 3: Check Quality Score** After processing completes: - ✅ Quality Score should be **0.70-1.00** (not 0.00) - ✅ Processing time: **30-60 minutes** for 10 files (not hours) - ✅ No timeout errors --- ## 🔍 Troubleshooting ### Issue: "Still seeing timeout errors" **Check 1**: Verify file was uploaded - Go to Files tab in your Space - Click app.py - Search for line 143 - Should say: `os.environ["USE_HF_API"] = "True"` - If it says `setdefault` instead, the file wasn't uploaded correctly **Check 2**: Verify token is set - Go to Settings tab - Look for HUGGINGFACE_TOKEN in secrets - If not there, add it from https://huggingface.co/settings/tokens **Check 3**: Force rebuild - Settings tab → "Factory reboot" - This clears all caches and rebuilds from scratch ### Issue: "Logs show 'USE_HF_API: False'" **Cause**: Old file still being used **Fix**: 1. Delete app.py from your Space 2. Upload the fixed version again 3. Factory reboot ### Issue: "HuggingFace token detected" not showing **Cause**: Token not set in Space secrets **Fix**: 1. Go to: https://huggingface.co/settings/tokens 2. Create new token (type: Read) 3. Go to Space → Settings → Repository secrets 4. Add: Name=HUGGINGFACE_TOKEN, Value=(your token) 5. Factory reboot --- ## 📋 Quick Checklist Before upload: - [x] Local app.py has `USE_HF_API = "True"` on line 143 ✓ (already confirmed) - [ ] HUGGINGFACE_TOKEN is set in Space secrets - [ ] Ready to upload file After upload: - [ ] File uploaded successfully - [ ] Space rebuilt (takes 2-3 minutes) - [ ] Logs show "Forcing HF API mode" - [ ] Logs show "USE_HF_API: True" - [ ] Logs show "LLM Backend: hf_api" - [ ] Test transcript processes without timeout - [ ] Quality Score > 0.00 --- ## 🎯 Expected Timeline 1. **Upload file**: 1 minute 2. **Space rebuild**: 2-3 minutes 3. **First transcript test**: 5-10 minutes (for a typical file) 4. **Total**: ~15 minutes to confirm it's working --- ## 📞 If Still Not Working After uploading and waiting for rebuild, if you still see timeout errors: 1. **Copy the startup logs** (first 50 lines) 2. **Copy the error logs** (when processing fails) 3. **Check these specific lines**: - Line showing "LLM Backend: ???" - Line showing "USE_HF_API: ???" - Line showing "Calling HF API" or "Generating with local model" This will help diagnose if the file uploaded correctly or if there's another issue. --- ## ✅ File is Ready - Just Upload It! Your local file at `/home/john/TranscriptorEnhanced/app.py` is **100% correct**. **All you need to do is**: 1. Copy it to your HuggingFace Space (Method 1, 2, or 3 above) 2. Wait for rebuild 3. Test! The timeout issue will be **completely resolved** once this file is on your Space. 🚀