Spaces:
Running
Running
A newer version of the Gradio SDK is available:
5.46.1
Deployment Guide for Hugging Face Spaces
Quick Deployment Steps
1. Create a New Space on Hugging Face
- Go to Hugging Face Spaces
- Click "Create new Space"
- Choose:
- Space name:
fitness-ai-assistant
(or your preferred name) - License: MIT
- SDK: Gradio
- Space hardware: CPU basic (free tier) or GPU if needed
- Visibility: Public or Private
- Space name:
2. Clone Your New Space Repository
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
cd YOUR_SPACE_NAME
3. Add Your Code
Copy all files from your fitness-app directory to the cloned space directory:
app.py
(root level entry point)requirements.txt
README.md
(with HF frontmatter)fitness_agent/
directory with all your code.env.example
4. Set Environment Variables in Hugging Face
- Go to your Space settings on Hugging Face
- Navigate to "Repository secrets"
- Add these secrets:
OPENAI_API_KEY
: Your OpenAI API keyANTHROPIC_API_KEY
: Your Anthropic API key (if using Claude)
5. Push to Hugging Face
git add .
git commit -m "Initial deployment of Fitness AI Assistant"
git push origin main
6. Wait for Build
- Hugging Face will automatically build and deploy your space
- Check the build logs for any errors
- Once successful, your app will be available at:
https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
Troubleshooting
Common Issues:
- Import Errors: Make sure all dependencies are in
requirements.txt
- API Key Issues: Verify environment variables are set correctly in Space settings
- Memory Issues: Consider upgrading to a higher tier if using large models
- Timeout Issues: Increase
startup_duration_timeout
in README frontmatter
Testing Locally:
Before deploying, test your app locally:
pip install -r requirements.txt
python app.py
Advanced Configuration
Custom Hardware:
- For faster performance, consider upgrading to GPU hardware
- T4 small is good for most AI applications
Private Spaces:
- Set visibility to private if you want to control access
- Can still share via direct links
Custom Domain:
- Available for Pro subscribers
- Configure in Space settings
Monitoring
- Check Space analytics in the Hugging Face dashboard
- Monitor usage and performance
- Set up notifications for errors
Updates
To update your deployed app:
- Make changes locally
- Test thoroughly
- Commit and push to the HF repository
- HF will automatically redeploy