IntegraChat / NEXT_STEPS.md
nothingworry's picture
Deploy IntegraChat to Hugging Face Spaces - Full deployment with Docker, MCP server, FastAPI backend, and Gradio UI
852c966
# πŸš€ Next Steps to Deploy to Hugging Face Spaces
## βœ… What's Ready
- βœ… Dockerfile created
- βœ… .dockerignore created
- βœ… README_HF_SPACES.md created
- βœ… All deployment files committed
- βœ… Git remote configured: `hf` β†’ `https://huggingface.co/spaces/nothingworry/IntegraChat`
## πŸ“‹ Step-by-Step Instructions
### Step 1: Create Your Hugging Face Space
1. **Go to**: https://huggingface.co/new-space
2. **Fill in the form**:
- **Space name**: `IntegraChat` (must match your remote)
- **SDK**: Select **Docker** ⚠️ (IMPORTANT!)
- **Hardware**:
- **CPU basic** (free) - for testing
- **CPU upgrade** (paid) - for better performance
- **Visibility**: Public or Private
3. **Click "Create Space"**
### Step 2: Authenticate with Hugging Face
You need to authenticate before pushing. Choose one method:
#### Option A: Using Hugging Face CLI (Recommended)
```powershell
# Install HF CLI if not already installed
pip install huggingface_hub
# Login
huggingface-cli login
# Enter your token when prompted
```
#### Option B: Using Git Credentials
```powershell
# Set your HF token as credential helper
git config --global credential.helper store
# Then push - it will prompt for username and token
```
#### Option C: Use Token in URL (One-time)
```powershell
git remote set-url hf https://USERNAME:TOKEN@huggingface.co/spaces/nothingworry/IntegraChat
```
**Get your token from**: https://huggingface.co/settings/tokens
- Create a token with **"Write"** permissions
### Step 3: Push to Hugging Face
Once the Space is created and you're authenticated:
```powershell
git push hf main
```
If you get authentication errors, try:
```powershell
# Force push (if Space exists but is empty)
git push hf main --force
```
### Step 4: Configure Environment Variables
After pushing, go to your Space page:
**https://huggingface.co/spaces/nothingworry/IntegraChat**
1. Click **"Settings"** tab
2. Scroll to **"Repository secrets"** section
3. Add these environment variables:
#### Required:
```
POSTGRESQL_URL=postgresql://user:password@host:port/database
OLLAMA_URL=http://your-ollama-server:11434
OLLAMA_MODEL=llama3.1:latest
```
**OR** (if using Groq instead):
```
GROQ_API_KEY=your_groq_api_key
LLM_BACKEND=groq
```
#### Optional:
```
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_KEY=your_service_role_key
GOOGLE_SEARCH_API_KEY=your_google_api_key
GOOGLE_SEARCH_CX_ID=your_search_engine_id
```
### Step 5: Wait for Build
1. Go to **"Logs"** tab in your Space
2. Monitor the build progress (5-10 minutes for first build)
3. Look for:
- βœ… "Starting MCP server..."
- βœ… "Starting FastAPI backend..."
- βœ… "Starting Gradio UI..."
4. Once build completes, your Space will be live!
### Step 6: Test Your Deployment
1. **Access your Space**: https://huggingface.co/spaces/nothingworry/IntegraChat
2. **Test the UI**: Should see Gradio interface
3. **Test API**: Go to `https://your-space-url/api/docs` for FastAPI docs
4. **Test Health**: Check `https://your-space-url/api/health`
## πŸ”§ Troubleshooting
### "Repository not found" Error
- **Solution**: Create the Space first at https://huggingface.co/new-space
- Make sure Space name matches: `IntegraChat`
### Authentication Errors
- **Solution**: Run `huggingface-cli login` and enter your token
- Or use token in remote URL: `git remote set-url hf https://USERNAME:TOKEN@huggingface.co/spaces/nothingworry/IntegraChat`
### Build Fails
- Check **Logs** tab for specific errors
- Common issues:
- Missing environment variables
- Database connection errors
- Port conflicts
### Services Not Starting
- Check environment variables are set correctly
- Verify database is accessible from HF servers
- Check LLM service (Ollama/Groq) is accessible
## πŸ“ž Quick Commands Reference
```powershell
# Check remotes
git remote -v
# Check status
git status
# View commits
git log --oneline -5
# Push to HF (after Space is created)
git push hf main
# If authentication needed
huggingface-cli login
# Check Space exists
# Visit: https://huggingface.co/spaces/nothingworry/IntegraChat
```
## βœ… Checklist
- [ ] Created Hugging Face Space (Docker SDK)
- [ ] Authenticated with HF (huggingface-cli login)
- [ ] Pushed code to Space (git push hf main)
- [ ] Added environment variables in Space Settings
- [ ] Build completed successfully
- [ ] Tested Space is working
---
**Your Space URL**: https://huggingface.co/spaces/nothingworry/IntegraChat
**Need Help?** Check the Logs tab in your Space for detailed error messages.