Spaces:
Paused
Paused
Hugging Face Spaces Deployment Guide π€
Quick Deployment Steps
Step 1: Create a New Space
- Go to https://huggingface.co/spaces
- Click "Create new Space"
- Enter Space name:
graph-rag-chatbot - Select Owner: Your username
- License: MIT (or your preference)
- Space SDK: Docker
- Visibility: Public (or Private)
- Click "Create Space"
Step 2: Upload Files
After creation, clone the Space:
git clone https://huggingface.co/spaces/YOUR_USERNAME/graph-rag-chatbot
cd graph-rag-chatbot
# Copy all project files into this directory
cp -r /path/to/local/project/* .
# Add and commit
git add .
git commit -m "Initial Graph RAG chatbot deployment"
git push
The Space will automatically build and deploy once files are pushed.
Step 3: Configure Secrets
- Go to your Space page β Settings
- Scroll to "Repository secrets"
- Add a new secret:
- Name:
GROQ_API_KEY - Value: Paste your Groq API key (from https://console.groq.com)
- Name:
- Click "Add secret"
The app will automatically use this environment variable.
Files Structure for HF Spaces
your-space-repo/
βββ Dockerfile # Docker image definition
βββ app.py # Main Flask application
βββ requirements.txt # Python dependencies
βββ .dockerignore # Files to skip
βββ templates/
β βββ index.html # Frontend
βββ README.md # Documentation
What HF Spaces Does
- Detects Dockerfile: Automatically reads and executes it
- Builds Image: Installs all dependencies from requirements.txt
- Runs Container: Starts your app on port 7860 (default HF Spaces port)
- Injects Secrets: Environment variables are automatically available
- Public URL: Your app is accessible at https://huggingface.co/spaces/YOUR_USERNAME/graph-rag-chatbot
Important Notes
Port Configuration
- HF Spaces automatically exposes port 7860
- Our Dockerfile and app use port 7860 β
- No changes needed!
Environment Variables
- HF Spaces automatically injects secrets as environment variables
- Our app reads:
os.getenv('GROQ_API_KEY') - This automatically works! β
Storage
/app/datadirectory persists between deployments- Uploaded files and graphs are stored here
- Note: HF Spaces has ephemeral storage by default
- Data is cleared when Space sleeps
- Upgrade to persistent storage if needed (paid feature)
CPU/GPU
- Free tier: 2 vCPU, 16GB RAM
- Sufficient for document processing
- Optional: Upgrade for faster embeddings
Troubleshooting HF Spaces Deployment
"App failed to build"
Check the build logs:
- Go to Space page β Settings
- Scroll to "Logs" section
- Review Docker build output
- Common issues:
- Wrong Dockerfile syntax
- Missing requirements
- File paths incorrect
"App is sleeping"
- Free tier spaces sleep after inactivity
- Click the Space to wake it up
- Or upgrade to a paid GPU/CPU tier
"GROQ_API_KEY not found"
- Verify secret is added in Space Settings
- Restart the Space (go to Settings β Restart)
- Wait 2-3 minutes for environment to reload
"Port connection refused"
- Ensure Dockerfile exposes port 7860
- Check
EXPOSE 7860is in Dockerfile β - Check
PORT=7860in environment
Example Dockerfile for HF Spaces
Our current Dockerfile is optimized for HF Spaces:
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y gcc g++ && rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application files
COPY app.py .
COPY templates/ templates/
# Create data directories
RUN mkdir -p data/uploads data/graph_data
# Set environment
ENV PORT=7860
EXPOSE 7860
# Run the app
CMD ["python", "app.py"]
β Ready for HF Spaces!
Monitoring and Logs
View Application Logs
- Space page β Settings β Logs
- Shows real-time application output
- Useful for debugging issues
Monitor Space Health
- Space page β Settings β Info
- Shows CPU/RAM usage
- Storage usage
- Build/deployment status
Upgrade Options
1. Persistent Storage
- Free tier: 50GB ephemeral
- Paid: Unlimited persistent storage
- Price: ~$5/month
2. GPU Support
- Free tier: 2vCPU CPU
- Paid: T4 GPU (
$6.50/day), A100 GPU ($9/day) - Benefit: 10-50x faster embeddings
3. Persistent CPU
- Free tier: Sleeps after inactivity
- Paid: Always on
- Prices vary by vCPU count
Deployment Complete! π
Your Graph RAG Chatbot is now live on Hugging Face Spaces!
Share your Space URL: https://huggingface.co/spaces/YOUR_USERNAME/graph-rag-chatbot
API Rate Limits (Groq)
- Free tier: 30 requests/minute
- Contact Groq for higher limits
- Implement caching to reduce API calls
Next Steps
- Upload test documents (PDF, CSV, TXT)
- Generate knowledge graphs
- Test the chat functionality
- Share your Space with others!
- Customize styling/features as needed
Questions? Check the main README.md for detailed documentation.