RAG PDF Assistant commited on
Commit
8f6d16d
Β·
1 Parent(s): 1b31f0c

docs: Add GitHub and HuggingFace Spaces setup guide

Browse files
Files changed (1) hide show
  1. GITHUB_HUGGINGFACE_SETUP.md +331 -0
GITHUB_HUGGINGFACE_SETUP.md ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GitHub & HuggingFace Setup Guide
2
+
3
+ ## πŸ“Š Current Status
4
+
5
+ βœ… **Git Repository Initialized**
6
+ βœ… **23 Files Committed**
7
+ βœ… **.gitignore Configured**
8
+ βœ… **Ready for GitHub Push**
9
+
10
+ ---
11
+
12
+ ## πŸš€ Step 1: Push to GitHub
13
+
14
+ ### If you have an existing GitHub repository:
15
+
16
+ ```bash
17
+ # Navigate to project
18
+ cd c:\Users\Ebi_Mahmdli\Desktop\rag_pdf_project
19
+
20
+ # Add GitHub remote (replace YOUR_USERNAME and REPO_NAME)
21
+ git remote add origin https://github.com/YOUR_USERNAME/rag_pdf_project.git
22
+
23
+ # Rename branch to main (optional but recommended)
24
+ git branch -M main
25
+
26
+ # Push to GitHub
27
+ git push -u origin main
28
+ ```
29
+
30
+ ### If you need to create a new GitHub repository:
31
+
32
+ 1. Go to https://github.com/new
33
+ 2. Create a new repository named `rag_pdf_project`
34
+ 3. Copy the repository URL
35
+ 4. Run:
36
+
37
+ ```bash
38
+ git remote add origin https://github.com/YOUR_USERNAME/rag_pdf_project.git
39
+ git branch -M main
40
+ git push -u origin main
41
+ ```
42
+
43
+ ---
44
+
45
+ ## πŸ€– Step 2: Deploy to HuggingFace Spaces
46
+
47
+ ### Option A: Easy Setup (Recommended)
48
+
49
+ 1. Go to https://huggingface.co/spaces/create
50
+ 2. Select **Space SDK: Gradio**
51
+ 3. Name it `rag-pdf-assistant`
52
+ 4. Click **Create Space**
53
+ 5. Upload the repository files or clone this repo
54
+
55
+ ### Option B: Command Line Setup
56
+
57
+ ```bash
58
+ # 1. Install huggingface-hub if not already installed
59
+ pip install huggingface-hub
60
+
61
+ # 2. Login to HuggingFace (get token from https://huggingface.co/settings/tokens)
62
+ huggingface-cli login
63
+
64
+ # 3. Create a new Space repository
65
+ huggingface-cli repo create rag-pdf-assistant --type space --space-sdk docker
66
+
67
+ # 4. Add HuggingFace as remote
68
+ git remote add hf https://huggingface.co/spaces/YOUR_HF_USERNAME/rag-pdf-assistant
69
+
70
+ # 5. Push to HuggingFace Spaces
71
+ git push hf main
72
+ ```
73
+
74
+ ### Option C: GitHub Actions (Auto-Deploy)
75
+
76
+ Create `.github/workflows/deploy-to-huggingface.yml`:
77
+
78
+ ```yaml
79
+ name: Deploy to HuggingFace Spaces
80
+
81
+ on:
82
+ push:
83
+ branches: [main]
84
+
85
+ jobs:
86
+ deploy:
87
+ runs-on: ubuntu-latest
88
+ steps:
89
+ - uses: actions/checkout@v3
90
+
91
+ - name: Push to HuggingFace
92
+ env:
93
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
94
+ run: |
95
+ git config --global user.email "action@github.com"
96
+ git config --global user.name "GitHub Action"
97
+ git remote add hf https://huggingface-ci:$HF_TOKEN@huggingface.co/spaces/YOUR_HF_USERNAME/rag-pdf-assistant
98
+ git push hf main --force
99
+ ```
100
+
101
+ Then add your HF_TOKEN to GitHub Secrets.
102
+
103
+ ---
104
+
105
+ ## πŸ“ GitHub Repository Files
106
+
107
+ Your repository now includes:
108
+
109
+ ```
110
+ βœ… README.md - Project overview with HF info
111
+ βœ… LICENSE - MIT License
112
+ βœ… .gitignore - Excludes cache, models, .venv
113
+ βœ… .env.example - Environment variables template
114
+ βœ… requirements.txt - All dependencies
115
+ βœ… QUICK_START.md - Quick start guide
116
+ βœ… TECHNICAL_DOCS.md - Architecture documentation
117
+ βœ… EXAMPLES_AND_TESTS.md - Examples and debugging
118
+ βœ… PROJECT_STATUS.md - Project completion report
119
+ βœ… app.py - Main Gradio application
120
+ βœ… main.py - CLI alternative
121
+ βœ… All source code files
122
+ ```
123
+
124
+ ---
125
+
126
+ ## 🎯 HuggingFace Spaces Configuration
127
+
128
+ The project is already configured for HuggingFace Spaces with:
129
+
130
+ ### βœ… Already Configured in README.md
131
+
132
+ ```yaml
133
+ ---
134
+ title: RAG PDF Assistant
135
+ emoji: πŸ“„
136
+ colorFrom: blue
137
+ colorTo: indigo
138
+ sdk: gradio
139
+ app_file: app.py
140
+ pinned: true
141
+ ---
142
+ ```
143
+
144
+ ### βœ… Gradio App Ready
145
+
146
+ - `app.py` is the main entry point
147
+ - Gradio interface configured
148
+ - Models auto-download on first run
149
+ - HuggingFace models used (transformers, sentence-transformers)
150
+
151
+ ### βœ… Docker Compatible
152
+
153
+ The project works with HuggingFace's Docker deployment:
154
+ - Python 3.10+ compatible
155
+ - All dependencies in requirements.txt
156
+ - No external API keys required (models on HuggingFace Hub)
157
+
158
+ ---
159
+
160
+ ## πŸ” Environment Variables
161
+
162
+ For local development, create `.env`:
163
+
164
+ ```bash
165
+ cp .env.example .env
166
+ ```
167
+
168
+ Edit `.env` with your settings:
169
+
170
+ ```
171
+ HF_TOKEN=your_huggingface_token
172
+ GRADIO_SHARE=False
173
+ GRADIO_SERVER_PORT=7860
174
+ ```
175
+
176
+ ---
177
+
178
+ ## πŸ“Š Git Commands Reference
179
+
180
+ ### Check git status
181
+ ```bash
182
+ cd c:\Users\Ebi_Mahmdli\Desktop\rag_pdf_project
183
+ git status
184
+ ```
185
+
186
+ ### View commit history
187
+ ```bash
188
+ git log --oneline
189
+ ```
190
+
191
+ ### Make changes and commit
192
+ ```bash
193
+ git add .
194
+ git commit -m "Description of changes"
195
+ git push origin main
196
+ ```
197
+
198
+ ### Push to multiple remotes
199
+ ```bash
200
+ git push origin main # GitHub
201
+ git push hf main # HuggingFace Spaces
202
+ ```
203
+
204
+ ---
205
+
206
+ ## πŸš€ Deployment Checklist
207
+
208
+ - [ ] GitHub repository created
209
+ - [ ] Git remote added (`git remote -v` shows origin)
210
+ - [ ] Code pushed to GitHub (`git push origin main`)
211
+ - [ ] HuggingFace Spaces repository created
212
+ - [ ] HuggingFace remote added
213
+ - [ ] Code pushed to HuggingFace (`git push hf main`)
214
+ - [ ] Space deployed successfully
215
+ - [ ] App accessible at `https://huggingface.co/spaces/YOUR_USERNAME/rag-pdf-assistant`
216
+
217
+ ---
218
+
219
+ ## πŸ“± Share Your Project
220
+
221
+ ### Share GitHub Repository
222
+ ```
223
+ https://github.com/YOUR_USERNAME/rag_pdf_project
224
+ ```
225
+
226
+ ### Share HuggingFace Spaces
227
+ ```
228
+ https://huggingface.co/spaces/YOUR_HF_USERNAME/rag-pdf-assistant
229
+ ```
230
+
231
+ ### Create a Shortlink
232
+ - GitHub: Use GitHub's built-in shortened URLs
233
+ - HuggingFace: Use bit.ly or short.link services
234
+
235
+ ---
236
+
237
+ ## 🀝 Collaboration
238
+
239
+ ### Invite Collaborators (GitHub)
240
+ 1. Go to repository Settings
241
+ 2. Click "Manage access"
242
+ 3. Click "Invite teams or people"
243
+ 4. Add collaborator email
244
+
245
+ ### Share HuggingFace Space
246
+ 1. HuggingFace Spaces are public by default
247
+ 2. Anyone can use the web UI
248
+ 3. Community members can fork and create derivatives
249
+
250
+ ---
251
+
252
+ ## πŸ“ˆ Monitor Your Deployment
253
+
254
+ ### GitHub
255
+ - Check "Insights" tab for statistics
256
+ - View "Actions" for workflow status
257
+ - Monitor "Issues" and "Discussions"
258
+
259
+ ### HuggingFace Spaces
260
+ - Check app logs in Space settings
261
+ - View traffic statistics
262
+ - See community comments
263
+
264
+ ---
265
+
266
+ ## πŸ”„ Continuous Updates
267
+
268
+ ### Update from GitHub
269
+ ```bash
270
+ # Make changes locally
271
+ git add .
272
+ git commit -m "Fix: issue description"
273
+ git push origin main
274
+
275
+ # Also push to HuggingFace
276
+ git push hf main
277
+ ```
278
+
279
+ ### Pull from GitHub (if working on multiple machines)
280
+ ```bash
281
+ git pull origin main
282
+ ```
283
+
284
+ ---
285
+
286
+ ## πŸ†˜ Troubleshooting
287
+
288
+ ### Issue: "fatal: not a git repository"
289
+ - **Solution**: Make sure you're in project directory
290
+ ```bash
291
+ cd c:\Users\Ebi_Mahmdli\Desktop\rag_pdf_project
292
+ ```
293
+
294
+ ### Issue: "Permission denied" when pushing
295
+ - **Solution**: Check GitHub credentials
296
+ ```bash
297
+ git config --list | grep url
298
+ ```
299
+
300
+ ### Issue: "Branch 'main' not found"
301
+ - **Solution**: Rename branch
302
+ ```bash
303
+ git branch -M main
304
+ ```
305
+
306
+ ### Issue: HuggingFace Space deployment fails
307
+ - **Solution**: Check app.py and requirements.txt are in root
308
+ - Ensure no API keys hardcoded in code
309
+ - Check models are from HuggingFace Hub
310
+
311
+ ---
312
+
313
+ ## πŸ“ž Next Steps
314
+
315
+ 1. **Create GitHub repository** (if not already created)
316
+ 2. **Push code to GitHub**
317
+ 3. **Create HuggingFace Space**
318
+ 4. **Deploy to HuggingFace Spaces**
319
+ 5. **Share the links with your team!**
320
+
321
+ ---
322
+
323
+ ## πŸŽ‰ Project Status
324
+
325
+ **Repository**: βœ… Initialized and committed
326
+ **GitHub**: ⏳ Awaiting push
327
+ **HuggingFace**: ⏳ Awaiting setup
328
+ **Documentation**: βœ… Complete
329
+ **Application**: βœ… Running and tested
330
+
331
+ Ready to push! πŸš€