Spaces:
Running
Running
A newer version of the Gradio SDK is available:
6.1.0
Hugging Face Spaces Deployment Guide
Files Created for Deployment
- app.py (root) - Main application file configured for Hugging Face Spaces
- requirements.txt - Minimal dependencies needed for the app
- README.md - Space metadata and description
Deployment Steps
1. Prepare Your Repository
The current file structure should work. The app.py in the root will automatically detect files in src/ or root directories.
2. Create a Hugging Face Space
- Go to Hugging Face Spaces
- Click "Create new Space"
- Choose:
- SDK: Gradio
- Python version: 3.10 or higher
- Hardware: CPU (or GPU if needed)
- Visibility: Public or Private
3. Push Your Code
You can either:
Option A: Using Git
# Initialize git if not already done
git init
git add app.py requirements.txt README.md src/
git commit -m "Deploy to Hugging Face Spaces"
git remote add origin https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
git push -u origin main
Option B: Using Hugging Face CLI
pip install huggingface_hub
huggingface-cli login
# Then upload files through the web interface or use the API
4. Set Environment Variables
- Go to your Space settings
- Navigate to "Variables and secrets"
- Add a new secret:
- Name:
OPENAI_API_KEY - Value: Your OpenAI API key
- Name:
5. Verify File Structure
Make sure these files/folders are in your Space:
βββ app.py
βββ requirements.txt
βββ README.md
βββ src/
βββ cv/
β βββ me.txt
β βββ avatar.jpeg
βββ projects_images/
βββ s_up.jpeg
βββ llm.jpeg
βββ bi.png
βββ robot.png
6. Wait for Build
The Space will automatically build and deploy. You can monitor the build logs in the Space interface.
Troubleshooting
- File not found errors: Make sure all files in
src/are committed and pushed - API key errors: Verify
OPENAI_API_KEYis set as a secret (not a variable) - Import errors: Check that
requirements.txtincludes all necessary packages
Notes
- The app.py automatically detects file paths (works with both
src/and root-level files) - Make sure
.envfile is NOT committed (it's in .gitignore) - The app uses Hugging Face Space secrets for the API key