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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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! π
|