Deploying Your Personal AI Assistant to Hugging Face Spaces
This guide provides detailed instructions for deploying your Personal AI Assistant with RAG to Hugging Face Spaces.
Prerequisites
Before you start, make sure you have:
- A Hugging Face Account: Sign up at https://huggingface.co/join if you don't have one
- Hugging Face API Token: Create a token at https://huggingface.co/settings/tokens
- Git: Installed and configured on your machine
- Python 3.8+: With pip for installing packages
Step 1: Install Dependencies
First, install all required packages:
pip install -r requirements.txt
Make sure you have the huggingface_hub package installed:
pip install huggingface_hub
Step 2: Check Your Git Configuration
Run the check script to ensure your Git is properly configured:
python check_git_status.py
This will:
- Verify Git is installed
- Check your Git configuration
- Confirm your repository status
- Verify Hugging Face configuration
Follow any prompts to fix issues that are detected.
Step 3: Deploy to Hugging Face Spaces
Run the deployment script:
python deploy_to_hf.py
You will be prompted to enter:
- Your Hugging Face username
- Your Hugging Face API token
- A name for your Space (or accept the default: personal-rag-assistant)
The script will:
- Configure your environment
- Create a new Hugging Face Space
- Set up Git for pushing to Hugging Face
- Push your code to the Space
Step 4: Monitor the Deployment
After pushing your code:
- Visit https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
- You'll see a "Building" status while Hugging Face builds your Docker container
- This may take 5-10 minutes for the first build
Step 5: Using Your Deployed Assistant
Once deployment is complete:
- Your app will be accessible at https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
- Upload documents through the sidebar
- Start asking questions about your documents
- The application automatically saves your conversation history
Troubleshooting
Authentication Issues
If you encounter Git authentication issues:
remote: HTTP Basic: Access denied
This usually means:
- Your Hugging Face token is invalid or expired
- You haven't configured Git to use your token
Solution: Re-run the deployment script to update your credentials.
Build Failures
If your Space shows a build failure:
- Check the build logs in the Hugging Face Space UI
- Common issues include:
- Missing dependencies in requirements.txt
- Issues with the Dockerfile
- Errors in your Python code
Space Creation Errors
If the Space creation fails:
- Try creating the Space manually in the Hugging Face UI
- Then run the deployment script again, which will detect the existing Space
Managing Your Space
After deployment, you can:
- Update Your App: Make changes locally, then run
python deploy_to_hf.py
again - Change Hardware: Upgrade to a more powerful instance in the Hugging Face UI
- Monitor Usage: View usage statistics in the Hugging Face UI
- Share Your App: Share the URL with others to use your assistant