|
# 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: |
|
|
|
1. **A Hugging Face Account**: Sign up at [https://huggingface.co/join](https://huggingface.co/join) if you don't have one |
|
2. **Hugging Face API Token**: Create a token at [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) |
|
3. **Git**: Installed and configured on your machine |
|
4. **Python 3.8+**: With pip for installing packages |
|
|
|
## Step 1: Install Dependencies |
|
|
|
First, install all required packages: |
|
|
|
```bash |
|
pip install -r requirements.txt |
|
``` |
|
|
|
Make sure you have the huggingface_hub package installed: |
|
|
|
```bash |
|
pip install huggingface_hub |
|
``` |
|
|
|
## Step 2: Check Your Git Configuration |
|
|
|
Run the check script to ensure your Git is properly configured: |
|
|
|
```bash |
|
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: |
|
|
|
```bash |
|
python deploy_to_hf.py |
|
``` |
|
|
|
You will be prompted to enter: |
|
1. Your Hugging Face username |
|
2. Your Hugging Face API token |
|
3. 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: |
|
|
|
1. Visit [https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME](https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME) |
|
2. You'll see a "Building" status while Hugging Face builds your Docker container |
|
3. This may take 5-10 minutes for the first build |
|
|
|
## Step 5: Using Your Deployed Assistant |
|
|
|
Once deployment is complete: |
|
|
|
1. Your app will be accessible at [https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME](https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME) |
|
2. Upload documents through the sidebar |
|
3. Start asking questions about your documents |
|
4. 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: |
|
|
|
1. Check the build logs in the Hugging Face Space UI |
|
2. 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: |
|
|
|
1. Try creating the Space manually in the Hugging Face UI |
|
2. 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 |
|
|
|
## Additional Resources |
|
|
|
- [Hugging Face Spaces Documentation](https://huggingface.co/docs/hub/spaces) |
|
- [Streamlit Documentation](https://docs.streamlit.io/) |
|
- [LangChain Documentation](https://python.langchain.com/docs/) |