File size: 4,558 Bytes
852c966
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# πŸš€ 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.