Spaces:
Runtime error
Runtime error
File size: 2,065 Bytes
8d0b054 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# 🚀 Deploying to Hugging Face Spaces
## Quick Setup
1. **Create a new Space**:
- Go to https://huggingface.co/new-space
- Choose "Docker" as SDK
- Set visibility to "Public"
2. **Upload Files**:
Upload these files to your Space repository:
```
app.py
events.py
requirements.txt
Dockerfile
.dockerignore
templates/
static/
```
3. **Set Environment Variables**:
In your Space settings, add these secrets:
**Required:**
- `PAY_TO_ADDRESS`: Your wallet address for receiving payments
- `X402_NETWORK`: `base-sepolia`
**Optional (for revenue splitting):**
- `CDP_API_KEY_ID`: Your CDP API key ID
- `CDP_API_KEY_SECRET`: Your CDP API key secret
- `CDP_WALLET_SECRET`: Your CDP wallet secret
- `DEV_WALLET`: Developer wallet address
- `HF_WALLET`: Hugging Face wallet address
- `AWS_WALLET`: AWS wallet address
**Optional (for image generation):**
- `AWS_ACCESS_KEY_ID`: Your AWS access key
- `AWS_SECRET_ACCESS_KEY`: Your AWS secret key
- `AWS_REGION`: `us-east-1`
4. **Build and Deploy**:
- Push files to your Space repository
- HF Spaces will automatically build using the Dockerfile
- First build takes ~5-10 minutes (downloading models)
- Subsequent builds are faster due to Docker layer caching
## Testing
1. Visit your Space URL
2. Connect MetaMask to Base Sepolia
3. Get testnet USDC from [Base Sepolia faucet](https://www.coinbase.com/faucets/base-ethereum-sepolia-faucet)
4. Test the three services:
- Text Generation ($0.01)
- Sentiment Analysis ($0.005)
- Image Generation ($0.02)
## Troubleshooting
- **Build fails**: Check logs for missing dependencies
- **Models loading slowly**: First startup takes time to download models
- **Payment fails**: Ensure MetaMask is on Base Sepolia with testnet USDC
- **Image generation fails**: Check AWS credentials and Bedrock model access
## Performance Notes
- **Memory**: ~4GB for all models
- **Startup**: ~30-60 seconds after build
- **Cold start**: ~10-20 seconds on first request
|