amitlals
commited on
Commit
·
dffa786
1
Parent(s):
9be8645
Add comprehensive HF authentication setup guide for gated model access
Browse files- HF_AUTHENTICATION_SETUP.md +119 -0
HF_AUTHENTICATION_SETUP.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# HuggingFace Authentication Setup for SAP RPT-1-OSS
|
| 2 |
+
|
| 3 |
+
The SAP Finance Dashboard uses the **SAP-RPT-1-OSS model**, which is a gated model on Hugging Face. To enable full functionality, you need to:
|
| 4 |
+
|
| 5 |
+
1. **Accept access to the gated model**
|
| 6 |
+
2. **Create a Hugging Face access token**
|
| 7 |
+
3. **Configure the token in HF Spaces**
|
| 8 |
+
|
| 9 |
+
## Step 1: Accept Gated Model Access
|
| 10 |
+
|
| 11 |
+
1. Visit: https://huggingface.co/SAP/sap-rpt-1-oss
|
| 12 |
+
2. Click the **"Agree"** button to accept access to the gated model
|
| 13 |
+
3. You may need to be logged in to your Hugging Face account
|
| 14 |
+
|
| 15 |
+
## Step 2: Create a Hugging Face Access Token
|
| 16 |
+
|
| 17 |
+
1. Go to: https://huggingface.co/settings/tokens
|
| 18 |
+
2. Click **"New token"**
|
| 19 |
+
3. **Token name**: `sap-rpt-oss-access` (or any descriptive name)
|
| 20 |
+
4. **Type**: Select **"Read"** (this token only needs to download models)
|
| 21 |
+
5. Click **"Create token"**
|
| 22 |
+
6. **Copy the token** (you won't be able to see it again!)
|
| 23 |
+
|
| 24 |
+
## Step 3: Add Token to HF Spaces
|
| 25 |
+
|
| 26 |
+
### Option A: Via HF Spaces Web UI (Recommended)
|
| 27 |
+
|
| 28 |
+
1. Go to your HF Space: https://huggingface.co/spaces/amitgpt/sap-finance-dashboard-RPT-1-OSS
|
| 29 |
+
2. Click **⚙ Settings** (top right)
|
| 30 |
+
3. Go to **"Repository secrets"** section
|
| 31 |
+
4. Click **"Add secret"**
|
| 32 |
+
5. **Name**: `HF_TOKEN`
|
| 33 |
+
6. **Value**: Paste your token from Step 2
|
| 34 |
+
7. Click **"Add secret"**
|
| 35 |
+
8. Wait for the Space to rebuild automatically (~2-5 minutes)
|
| 36 |
+
|
| 37 |
+
### Option B: Via Git (Alternative)
|
| 38 |
+
|
| 39 |
+
If using git to push directly, you can pass the token at build time:
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
# In your local repo
|
| 43 |
+
git push -u hf main # Push code changes
|
| 44 |
+
|
| 45 |
+
# Then add via HF Spaces UI as above
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
## Step 4: Verify Setup
|
| 49 |
+
|
| 50 |
+
1. After the Space rebuilds, wait 1-2 minutes
|
| 51 |
+
2. Refresh the Space URL
|
| 52 |
+
3. Check the logs (scroll down on the Space page)
|
| 53 |
+
4. Look for: **"✓ HuggingFace authentication configured"**
|
| 54 |
+
|
| 55 |
+
If you see this message, authentication is working!
|
| 56 |
+
|
| 57 |
+
## Troubleshooting
|
| 58 |
+
|
| 59 |
+
### Error: "401 Client Error: Unauthorized"
|
| 60 |
+
- **Cause**: Token not set or incorrect
|
| 61 |
+
- **Fix**:
|
| 62 |
+
1. Verify token was accepted in HF Spaces secrets (wait for rebuild)
|
| 63 |
+
2. Verify you have accepted model access (Step 1)
|
| 64 |
+
3. Create a new token if needed
|
| 65 |
+
|
| 66 |
+
### Error: "HF_TOKEN not found"
|
| 67 |
+
- **Cause**: Environment variable not set
|
| 68 |
+
- **Fix**: Ensure the secret is named exactly `HF_TOKEN` (case-sensitive)
|
| 69 |
+
|
| 70 |
+
### Model still not loading
|
| 71 |
+
- **Cause**: Token may not have correct permissions
|
| 72 |
+
- **Fix**:
|
| 73 |
+
1. Delete old token
|
| 74 |
+
2. Create new token with "Read" permission
|
| 75 |
+
3. Accept model access again
|
| 76 |
+
4. Update HF Spaces secret
|
| 77 |
+
|
| 78 |
+
## Local Development
|
| 79 |
+
|
| 80 |
+
If developing locally, set the token in your environment:
|
| 81 |
+
|
| 82 |
+
```bash
|
| 83 |
+
# PowerShell
|
| 84 |
+
$env:HF_TOKEN = "hf_..."
|
| 85 |
+
|
| 86 |
+
# Or in .env file
|
| 87 |
+
echo "HF_TOKEN=hf_..." >> .env
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
Then run:
|
| 91 |
+
|
| 92 |
+
```bash
|
| 93 |
+
python app_gradio.py
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
## Security Best Practices
|
| 97 |
+
|
| 98 |
+
- **Never commit tokens to git** (they're in .gitignore)
|
| 99 |
+
- **Regenerate tokens if exposed** (go to HF settings)
|
| 100 |
+
- **Use "Read" permission only** for model access
|
| 101 |
+
- **Delete unused tokens** from HF settings
|
| 102 |
+
|
| 103 |
+
## What the Dashboard Does With the Token
|
| 104 |
+
|
| 105 |
+
The token is used **only** to download the SAP-RPT-1-OSS model weights from Hugging Face Hub. The dashboard:
|
| 106 |
+
- Does NOT collect or store your token
|
| 107 |
+
- Does NOT upload any data
|
| 108 |
+
- Does NOT modify your Hugging Face account
|
| 109 |
+
- Only reads the pre-trained model file
|
| 110 |
+
|
| 111 |
+
## Additional Resources
|
| 112 |
+
|
| 113 |
+
- HF Spaces Documentation: https://huggingface.co/docs/hub/spaces
|
| 114 |
+
- HF Tokens Guide: https://huggingface.co/docs/hub/security-tokens
|
| 115 |
+
- SAP RPT-1-OSS Model: https://huggingface.co/SAP/sap-rpt-1-oss
|
| 116 |
+
|
| 117 |
+
---
|
| 118 |
+
|
| 119 |
+
**After completing these steps, your SAP Finance Dashboard will have full access to the RPT-1-OSS model for predictions and analytics!**
|