CoolFace
Apppublic

Aigenthix/Graph_RAG7

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
space_config.md200 linesDownload Raw Back to root
1# Hugging Face Spaces Deployment Guide ๐Ÿค—2 3## Quick Deployment Steps4 5### Step 1: Create a New Space61. Go to https://huggingface.co/spaces72. Click "Create new Space"83. Enter Space name: `graph-rag-chatbot`94. Select Owner: Your username105. License: MIT (or your preference)116. Space SDK: **Docker**127. Visibility: Public (or Private)138. Click "Create Space"14 15### Step 2: Upload Files16After creation, clone the Space:17 18```bash19git clone https://huggingface.co/spaces/YOUR_USERNAME/graph-rag-chatbot20cd graph-rag-chatbot21 22# Copy all project files into this directory23cp -r /path/to/local/project/* .24 25# Add and commit26git add .27git commit -m "Initial Graph RAG chatbot deployment"28git push29```30 31The Space will automatically build and deploy once files are pushed.32 33### Step 3: Configure Secrets341. Go to your Space page โ†’ Settings352. Scroll to "Repository secrets"363. Add a new secret:37   - **Name**: `GROQ_API_KEY`38   - **Value**: Paste your Groq API key (from https://console.groq.com)394. Click "Add secret"40 41The app will automatically use this environment variable.42 43## Files Structure for HF Spaces44 45```46your-space-repo/47โ”œโ”€โ”€ Dockerfile              # Docker image definition48โ”œโ”€โ”€ app.py                  # Main Flask application49โ”œโ”€โ”€ requirements.txt        # Python dependencies50โ”œโ”€โ”€ .dockerignore          # Files to skip51โ”œโ”€โ”€ templates/52โ”‚   โ””โ”€โ”€ index.html        # Frontend53โ””โ”€โ”€ README.md             # Documentation54```55 56## What HF Spaces Does57 581. **Detects Dockerfile**: Automatically reads and executes it592. **Builds Image**: Installs all dependencies from requirements.txt603. **Runs Container**: Starts your app on port 7860 (default HF Spaces port)614. **Injects Secrets**: Environment variables are automatically available625. **Public URL**: Your app is accessible at https://huggingface.co/spaces/YOUR_USERNAME/graph-rag-chatbot63 64## Important Notes65 66### Port Configuration67- HF Spaces automatically exposes port **7860**68- Our Dockerfile and app use port 7860 โœ“69- No changes needed!70 71### Environment Variables72- HF Spaces automatically injects secrets as environment variables73- Our app reads: `os.getenv('GROQ_API_KEY')`74- This automatically works! โœ“75 76### Storage77- `/app/data` directory persists between deployments78- Uploaded files and graphs are stored here79- **Note**: HF Spaces has ephemeral storage by default80  - Data is cleared when Space sleeps81  - Upgrade to persistent storage if needed (paid feature)82 83### CPU/GPU84- Free tier: 2 vCPU, 16GB RAM85- Sufficient for document processing86- Optional: Upgrade for faster embeddings87 88## Troubleshooting HF Spaces Deployment89 90### "App failed to build"91Check the build logs:921. Go to Space page โ†’ Settings932. Scroll to "Logs" section943. Review Docker build output954. Common issues:96   - Wrong Dockerfile syntax97   - Missing requirements98   - File paths incorrect99 100### "App is sleeping"101- Free tier spaces sleep after inactivity102- Click the Space to wake it up103- Or upgrade to a paid GPU/CPU tier104 105### "GROQ_API_KEY not found"1061. Verify secret is added in Space Settings1072. Restart the Space (go to Settings โ†’ Restart)1083. Wait 2-3 minutes for environment to reload109 110### "Port connection refused"111- Ensure Dockerfile exposes port 7860112- Check `EXPOSE 7860` is in Dockerfile โœ“113- Check `PORT=7860` in environment114 115## Example Dockerfile for HF Spaces116 117Our current Dockerfile is optimized for HF Spaces:118 119```dockerfile120FROM python:3.11-slim121WORKDIR /app122 123# Install system dependencies124RUN apt-get update && apt-get install -y gcc g++ && rm -rf /var/lib/apt/lists/*125 126# Install Python dependencies127COPY requirements.txt .128RUN pip install --no-cache-dir -r requirements.txt129 130# Copy application files131COPY app.py .132COPY templates/ templates/133 134# Create data directories135RUN mkdir -p data/uploads data/graph_data136 137# Set environment138ENV PORT=7860139EXPOSE 7860140 141# Run the app142CMD ["python", "app.py"]143```144 145โœ“ Ready for HF Spaces!146 147## Monitoring and Logs148 149### View Application Logs1501. Space page โ†’ Settings โ†’ Logs1512. Shows real-time application output1523. Useful for debugging issues153 154### Monitor Space Health1551. Space page โ†’ Settings โ†’ Info1562. Shows CPU/RAM usage1573. Storage usage1584. Build/deployment status159 160## Upgrade Options161 162### 1. Persistent Storage163- Free tier: 50GB ephemeral164- Paid: Unlimited persistent storage165- Price: ~$5/month166 167### 2. GPU Support168- Free tier: 2vCPU CPU169- Paid: T4 GPU (~$6.50/day), A100 GPU (~$9/day)170- Benefit: 10-50x faster embeddings171 172### 3. Persistent CPU173- Free tier: Sleeps after inactivity174- Paid: Always on175- Prices vary by vCPU count176 177## Deployment Complete! ๐ŸŽ‰178 179Your Graph RAG Chatbot is now live on Hugging Face Spaces!180 181**Share your Space URL**: https://huggingface.co/spaces/YOUR_USERNAME/graph-rag-chatbot182 183## API Rate Limits (Groq)184 185- Free tier: 30 requests/minute186- Contact Groq for higher limits187- Implement caching to reduce API calls188 189## Next Steps190 1911. Upload test documents (PDF, CSV, TXT)1922. Generate knowledge graphs1933. Test the chat functionality1944. Share your Space with others!1955. Customize styling/features as needed196 197---198 199**Questions?** Check the main README.md for detailed documentation.200