Spaces:
Running
Running
| # Hugging Face Spaces Deployment Guide | |
| ## Files Created for Deployment | |
| 1. **app.py** (root) - Main application file configured for Hugging Face Spaces | |
| 2. **requirements.txt** - Minimal dependencies needed for the app | |
| 3. **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 | |
| 1. Go to [Hugging Face Spaces](https://huggingface.co/spaces) | |
| 2. Click "Create new Space" | |
| 3. 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** | |
| ```bash | |
| # 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** | |
| ```bash | |
| pip install huggingface_hub | |
| huggingface-cli login | |
| # Then upload files through the web interface or use the API | |
| ``` | |
| ### 4. Set Environment Variables | |
| 1. Go to your Space settings | |
| 2. Navigate to "Variables and secrets" | |
| 3. Add a new secret: | |
| - **Name**: `OPENAI_API_KEY` | |
| - **Value**: Your OpenAI API key | |
| ### 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_KEY` is set as a secret (not a variable) | |
| - **Import errors**: Check that `requirements.txt` includes all necessary packages | |
| ## Notes | |
| - The app.py automatically detects file paths (works with both `src/` and root-level files) | |
| - Make sure `.env` file is NOT committed (it's in .gitignore) | |
| - The app uses Hugging Face Space secrets for the API key | |