File size: 4,570 Bytes
bc10808
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# Quick Start Guide ⚑

Get your Graph RAG Chatbot running in 5 minutes!

## Prerequisites

- Groq API Key (free at https://console.groq.com)
- One of: Docker, Python 3.8+, or Hugging Face account

---

## πŸš€ Fastest Way: Docker Compose (Recommended)

### 1. Get API Key
1. Visit https://console.groq.com
2. Sign up/Login
3. Click "API Keys" β†’ Create new API key
4. Copy the key

### 2. Configure
```bash
cd /path/to/project
cp .env.example .env
# Edit .env and paste your API key:
# GROQ_API_KEY=your_actual_key_here
```

### 3. Launch
```bash
docker-compose up -d
```

### 4. Access
Open browser: http://localhost:7860

βœ… **Done!** Your app is running.

---

## Alternative: Local Python Setup

### 1. Create environment
```bash
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
```

### 2. Install dependencies
```bash
pip install -r requirements.txt
```

### 3. Set API key
```bash
export GROQ_API_KEY="your_api_key_here"  # On Windows: set GROQ_API_KEY=...
```

### 4. Run app
```bash
python app.py
```

### 5. Access
Open: http://localhost:7860

---

## Alternative: Hugging Face Spaces (No local setup!)

### 1. Create Space
1. Go to https://huggingface.co/spaces
2. Click "Create new Space"
3. Select "Docker" SDK
4. Fill in details β†’ Create

### 2. Upload files
```bash
git clone https://huggingface.co/spaces/YOUR_USERNAME/graph-rag-chatbot
cd graph-rag-chatbot
cp /path/to/app.py .
cp /path/to/Dockerfile .
cp /path/to/requirements.txt .
cp -r /path/to/templates .
cp /path/to/.dockerignore .
git add -A
git commit -m "Initial upload"
git push
```

### 3. Add API key
In Space Settings β†’ Repository secrets:
- Name: `GROQ_API_KEY`
- Value: your_api_key

βœ… **Done!** App deploys automatically

---

## Using the Application

### Upload Documents

1. Click the upload area (or drag & drop)
2. Select PDF, CSV, or TXT file
3. Watch the progress bar
4. Status changes: queued β†’ processing β†’ ready

### View Knowledge Graph

1. Click "πŸ“ˆ View Full Graph" (appears when ready)
2. Or go to "Knowledge Graph" tab
3. Select document from dropdown

### Chat with Your Document

1. Select document from dropdown
2. Type your question
3. Click "Send" (or press Enter)
4. Read the answer!

---

## Test Files

### Quick CSV Test
Create `test.csv`:
```csv
Name,Role,Salary
Alice,Engineer,120000
Bob,Manager,110000
Carol,Designer,100000
```

Upload it and try asking:
- "Who is the highest paid?"
- "How many employees?"
- "What roles are in the data?"

---

## Troubleshooting

### "GROQ_API_KEY not found"
```bash
# Linux/Mac
echo "GROQ_API_KEY=your_key" >> .env

# Windows
echo GROQ_API_KEY=your_key >> .env
```

### Port 7860 in use?
```bash
# Find what's using it
lsof -i :7860  # Mac/Linux
netstat -ano | findstr :7860  # Windows

# Use different port
PORT=8000 python app.py
```

### Docker build fails?
```bash
# Clean and rebuild
docker-compose down
docker system prune -a
docker-compose up -d
```

### Model download slow?
The embedding model (~400MB) downloads once on first run. This is normal and can take 2-3 minutes. Subsequent runs are instant.

---

## Common Commands

```bash
# View logs
docker-compose logs -f

# Stop app
docker-compose down

# Restart
docker-compose restart

# See what's running
docker-compose ps

# Check file storage
ls -la data/
```

---

## Feature Overview

| Feature | Status | Notes |
|---|---|---|
| PDF Upload | βœ… | Up to 50MB |
| CSV Upload | βœ… | Auto-detected |
| TXT Upload | βœ… | Plain text |
| Knowledge Graph | βœ… | Auto-visualized |
| RAG Chat | βœ… | Uses Groq Mixtral |
| Real-time Updates | βœ… | Every 1.5s |
| Mobile UI | βœ… | Responsive |
| Multi-document | βœ… | Process in parallel |
| API Access | βœ… | JSON endpoints |

---

## API Quick Reference

```bash
# Upload file
curl -F "files=@document.pdf" http://localhost:7860/api/upload

# Get documents
curl http://localhost:7860/api/documents

# Query document
curl -X POST -H "Content-Type: application/json" \
  -d '{"query":"What is...?","document":"doc.pdf"}' \
  http://localhost:7860/api/query

# Delete document
curl -X DELETE http://localhost:7860/api/delete/doc.pdf
```

---

## Next Steps

1. βœ… App running locally? Perfect!
2. πŸ“€ Upload a test document
3. πŸ“ˆ View the knowledge graph
4. πŸ’¬ Try asking a question
5. πŸš€ Deploy to production (HF Spaces)

---

## Need Help?

1. Check `README.md` for detailed docs
2. See `TESTING.md` for test cases
3. Review `space_config.md` for HF deployment
4. Check logs: `docker-compose logs -f`

---

**You're all set! πŸŽ‰ Start exploring!**