diffron 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
docs/SETUP.md ADDED
@@ -0,0 +1,524 @@
1
+ # Diffron Setup Guide for Windows
2
+
3
+ Complete installation guide for Diffron on Windows with AMD Lemonade and GitHub Desktop.
4
+
5
+ **Diffron is a demo project showcasing the lemonade-python-sdk - submitted to the AMD Lemonade Developer Challenge 2026.**
6
+
7
+ ---
8
+
9
+ ## Table of Contents
10
+
11
+ 1. [Prerequisites](#prerequisites)
12
+ 2. [Step 1: Install Lemonade](#step-1-install-lemonade)
13
+ 3. [Step 2: Install Diffron](#step-2-install-diffron)
14
+ 4. [Step 3: Configure Environment](#step-3-configure-environment)
15
+ 5. [Step 4: Install Git Hooks](#step-4-install-git-hooks)
16
+ 6. [Step 5: Verify Installation](#step-5-verify-installation)
17
+ 7. [Changing the Model](#changing-the-model)
18
+ 8. [Troubleshooting](#troubleshooting)
19
+
20
+ ---
21
+
22
+ ## Prerequisites
23
+
24
+ | Software | Version | Purpose |
25
+ |----------|---------|---------|
26
+ | Python | 3.9+ | Runtime environment |
27
+ | Git | 2.0+ | Version control |
28
+ | GitHub Desktop | 3.5.5+ | Git GUI with hooks support |
29
+
30
+ ### Verify Prerequisites
31
+
32
+ ```bash
33
+ # Check Python
34
+ python --version
35
+
36
+ # Check Git
37
+ git --version
38
+
39
+ # Check GitHub Desktop version
40
+ # Open GitHub Desktop → Help → About
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Step 1: Install AMD Lemonade Server
46
+
47
+ **Lemonade is AMD's local LLM server for Ryzen AI PCs.**
48
+
49
+ ### 1.1 Download Lemonade Installer
50
+
51
+ 1. Go to [AMD Lemonade Releases](https://github.com/AMD-AI-Software/lemonade/releases)
52
+ 2. Download `Lemonade_Server_Installer.exe` (latest version)
53
+
54
+ ### 1.2 Install Lemonade
55
+
56
+ 1. Run the installer
57
+ 2. Follow the installation wizard
58
+ 3. Desktop shortcut `lemonade_server` will be created
59
+
60
+ ### 1.3 Start Lemonade and Download Model
61
+
62
+ 1. Double-click the `lemonade_server` desktop shortcut
63
+ 2. In the Lemonade UI, download a model (e.g., `qwen2.5-it-3b-FLM`)
64
+ 3. Server starts automatically on `http://localhost:8020`
65
+
66
+ ### 1.4 Verify Lemonade is Running
67
+
68
+ ```bash
69
+ curl http://localhost:8020/api/v1/models
70
+ ```
71
+
72
+ 📚 **Official Documentation:** [AMD Ryzen AI - Lemonade Setup](https://ryzenai.docs.amd.com/en/latest/llm/server_interface.html)
73
+
74
+ ---
75
+
76
+ ## Step 2: Install lemonade-python-sdk
77
+
78
+ **Our Python SDK for AMD Lemonade API - AMD Lemonade Challenge Submission**
79
+
80
+ ```bash
81
+ pip install lemonade-sdk
82
+ ```
83
+
84
+ 🔗 **Source:** [github.com/Tetramatrix/lemonade-python-sdk](https://github.com/Tetramatrix/lemonade-python-sdk)
85
+
86
+ ---
87
+
88
+ ## Step 4: Install Diffron
89
+
90
+ ### Option A: From PyPI (Recommended)
91
+
92
+ ```bash
93
+ pip install diffron
94
+ ```
95
+
96
+ ### Option B: From Source (Development)
97
+
98
+ ```bash
99
+ # Clone repository
100
+ git clone https://github.com/Tetramatrix/diffron.git
101
+ cd diffron
102
+
103
+ # Install in development mode
104
+ pip install -e .
105
+ ```
106
+
107
+ ### Verify Installation
108
+
109
+ ```bash
110
+ python -c "import diffron; print(f'Diffron v{diffron.__version__}')"
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Step 5: Configure Environment
116
+
117
+ ### 5.1 Set Lemonade Server URL (System-Wide)
118
+
119
+ **Method 1: Windows Environment Variables (Permanent)**
120
+
121
+ 1. Press `Win + X` → System
122
+ 2. Click "Advanced system settings"
123
+ 3. Click "Environment Variables"
124
+ 4. Under "User variables" or "System variables", click "New"
125
+ 5. Add:
126
+ - **Variable name:** `LEMONADE_SERVER_URL`
127
+ - **Variable value:** `http://localhost:8020`
128
+ 6. Click OK
129
+
130
+ **Method 2: Command Line (Current Session)**
131
+
132
+ ```cmd
133
+ set LEMONADE_SERVER_URL=http://localhost:8020
134
+ ```
135
+
136
+ **Method 3: PowerShell (Current Session)**
137
+
138
+ ```powershell
139
+ $env:LEMONADE_SERVER_URL="http://localhost:8020"
140
+ ```
141
+
142
+ ### 5.2 Optional: Set Custom Model
143
+
144
+ ```cmd
145
+ # System-wide (permanent)
146
+ setx DIFFRON_MODEL "qwen2.5-it-3b-FLM"
147
+
148
+ # Current session only
149
+ set DIFFRON_MODEL=qwen2.5-it-3b-FLM
150
+ ```
151
+
152
+ ### 5.3 Verify Environment Variables
153
+
154
+ ```bash
155
+ # Check LEMONADE_SERVER_URL
156
+ echo %LEMONADE_SERVER_URL%
157
+
158
+ # Check DIFFRON_MODEL
159
+ echo %DIFFRON_MODEL%
160
+ ```
161
+
162
+ ---
163
+
164
+ ## Step 6: Install Git Hooks
165
+
166
+ Git hooks enable automatic commit message generation.
167
+
168
+ ### 6.1 Global Installation (All Repositories)
169
+
170
+ **Recommended for most users.**
171
+
172
+ ```bash
173
+ python -c "from diffron.git_hooks import install_hooks; install_hooks(global_install=True)"
174
+ ```
175
+
176
+ This installs hooks to `C:\Users\YourName\.diffron-hooks` and configures Git globally.
177
+
178
+ ### 6.2 Per-Repository Installation
179
+
180
+ For specific repositories only:
181
+
182
+ ```bash
183
+ cd path\to\your\repository
184
+ python -c "from diffron.git_hooks import install_hooks; install_hooks(repo_path='.')"
185
+ ```
186
+
187
+ ### 6.3 Verify Hooks Installation
188
+
189
+ ```bash
190
+ # Check global hooks path
191
+ git config --global core.hooksPath
192
+
193
+ # Should output: C:/Users/YourName/.diffron-hooks
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Step 7: Verify Installation
199
+
200
+ ### 7.1 Run Status Check
201
+
202
+ ```bash
203
+ python -c "from diffron import is_lemonade_running, is_hooks_installed; print('Lemonade:', is_lemonade_running()); print('Hooks:', is_hooks_installed(check_global=True))"
204
+ ```
205
+
206
+ Expected output:
207
+ ```
208
+ Lemonade: True
209
+ Hooks: True
210
+ ```
211
+
212
+ ### 7.2 Test Commit Message Generation
213
+
214
+ ```bash
215
+ # Create a test repository
216
+ mkdir test-diffron
217
+ cd test-diffron
218
+ git init
219
+
220
+ # Create a test file
221
+ echo "Hello World" > test.txt
222
+ git add test.txt
223
+
224
+ # Commit (hooks will generate message)
225
+ git commit -m "test"
226
+ ```
227
+
228
+ Expected output:
229
+ ```
230
+ [master abc123] feat: add test.txt file
231
+ 1 file changed, 1 insertion(+)
232
+ create mode 100644 test.txt
233
+ ```
234
+
235
+ ---
236
+
237
+ ## Changing the Model
238
+
239
+ ### Option 1: Environment Variable (Recommended)
240
+
241
+ **System-wide:**
242
+ ```cmd
243
+ setx DIFFRON_MODEL "your-model-name"
244
+ ```
245
+
246
+ **Current session:**
247
+ ```cmd
248
+ set DIFFRON_MODEL=your-model-name
249
+ ```
250
+
251
+ ### Option 2: Python API
252
+
253
+ ```python
254
+ from diffron import DiffronClient
255
+
256
+ # Specify model directly
257
+ client = DiffronClient(model="your-model-name")
258
+
259
+ # Generate commit message
260
+ msg = client.generate_commit_message()
261
+ ```
262
+
263
+ ### Option 3: Modify Default in Source
264
+
265
+ Edit `diffron/lemonade.py`:
266
+
267
+ ```python
268
+ DEFAULT_MODEL = "your-model-name" # Change this line
269
+ ```
270
+
271
+ ### Available Models
272
+
273
+ Common models compatible with Lemonade:
274
+
275
+ | Model | Size | Use Case |
276
+ |-------|------|----------|
277
+ | `qwen2.5-it-3b-FLM` | 3B | Default, balanced |
278
+ | `qwen2.5-coder-7b` | 7B | Code-focused |
279
+ | `llama-3.2-3b` | 3B | General purpose |
280
+ | `mistral-7b` | 7B | High quality |
281
+
282
+ ---
283
+
284
+ ## How Git Hooks Work
285
+
286
+ ### Architecture
287
+
288
+ ```
289
+ ┌─────────────────────────────────────────────────────────┐
290
+ │ 1. User clicks "Commit" in GitHub Desktop │
291
+ │ - Or runs: git commit -m "anything" │
292
+ └─────────────────────────────────────────────────────────┘
293
+
294
+ ┌─────────────────────────────────────────────────────────┐
295
+ │ 2. Git executes prepare-commit-msg hook │
296
+ │ - Location: C:/Users/Name/.diffron-hooks/ │
297
+ │ - Wrapper: prepare-commit-msg (shell script) │
298
+ │ - Python: prepare-commit-msg.py │
299
+ └─────────────────────────────────────────────────────────┘
300
+
301
+ ┌─────────────────────────────────────────────────────────┐
302
+ │ 3. Hook reads staged diff │
303
+ │ - Runs: git diff --cached │
304
+ │ - Limits to 4000 characters │
305
+ └─────────────────────────────────────────────────────────┘
306
+
307
+ ┌─────────────────────────────────────────────────────────┐
308
+ │ 4. Hook calls Lemonade API │
309
+ │ - URL: http://localhost:8020/api/v1 │
310
+ │ - Model: qwen2.5-it-3b-FLM │
311
+ │ - Prompt: "Write a Conventional Commit message..." │
312
+ └─────────────────────────────────────────────────────────┘
313
+
314
+ ┌─────────────────────────────────────────────────────────┐
315
+ │ 5. Hook writes generated message │
316
+ │ - Replaces commit message in .git/COMMIT_EDITMSG │
317
+ │ - Git opens editor with generated message │
318
+ └─────────────────────────────────────────────────────────┘
319
+ ```
320
+
321
+ ### Hook Files
322
+
323
+ **Global hooks location:** `C:\Users\YourName\.diffron-hooks\`
324
+
325
+ | File | Purpose |
326
+ |------|---------|
327
+ | `prepare-commit-msg` | Shell wrapper (calls Python script) |
328
+ | `prepare-commit-msg.py` | Python hook logic |
329
+
330
+ ### Hook Behavior
331
+
332
+ | Scenario | Behavior |
333
+ |----------|----------|
334
+ | Lemonade running | Generates commit message |
335
+ | Lemonade not running | Silently skips, allows manual commit |
336
+ | Merge commit | Skips (doesn't interfere) |
337
+ | Rebase | Skips (doesn't interfere) |
338
+ | `git commit --amend` | Skips (doesn't interfere) |
339
+ | Empty commit | Skips (no diff to analyze) |
340
+
341
+ ### Disable Hooks Temporarily
342
+
343
+ ```bash
344
+ # Bypass hooks for single commit
345
+ git commit -m "manual message" --no-verify
346
+
347
+ # Or uninstall hooks
348
+ python -c "from diffron.git_hooks import uninstall_hooks; uninstall_hooks(global_install=True)"
349
+ ```
350
+
351
+ ---
352
+
353
+ ## GitHub Desktop Integration
354
+
355
+ ### Requirements
356
+
357
+ - **GitHub Desktop 3.5.5+** (required for hooks support on Windows)
358
+ - Hooks installed globally or per-repository
359
+
360
+ ### Workflow
361
+
362
+ 1. **Make changes** in your repository
363
+ 2. **Open GitHub Desktop** - changes appear automatically
364
+ 3. **Enter any commit message** (e.g., "auto")
365
+ 4. **Click "Commit to main"**
366
+ 5. **Diffron replaces** your message with AI-generated message
367
+
368
+ ### Example
369
+
370
+ ```
371
+ Before commit: "test"
372
+ After commit: "feat: add user authentication module"
373
+ ```
374
+
375
+ ### Troubleshooting GitHub Desktop
376
+
377
+ **Problem:** Hooks don't execute
378
+
379
+ **Solutions:**
380
+
381
+ 1. **Update GitHub Desktop:**
382
+ - Help → Check for Updates
383
+ - Must be version 3.5.5 or later
384
+
385
+ 2. **Verify hooks path:**
386
+ ```bash
387
+ git config --global core.hooksPath
388
+ ```
389
+
390
+ 3. **Restart GitHub Desktop** after installing hooks
391
+
392
+ ---
393
+
394
+ ## VS Code Integration
395
+
396
+ ### Using Git in VS Code
397
+
398
+ 1. Make changes
399
+ 2. Open Source Control panel (Ctrl+Shift+G)
400
+ 3. Enter any message in commit input
401
+ 4. Click commit button (or Ctrl+Enter)
402
+ 5. Diffron generates the message
403
+
404
+ ### Using Terminal in VS Code
405
+
406
+ ```bash
407
+ # Standard commit (hooks run automatically)
408
+ git add .
409
+ git commit -m "auto"
410
+ ```
411
+
412
+ ---
413
+
414
+ ## Troubleshooting
415
+
416
+ ### Lemonade Not Detected
417
+
418
+ **Error:** `ConnectionError: Could not detect Lemonade server`
419
+
420
+ **Solutions:**
421
+
422
+ 1. **Start Lemonade:**
423
+ ```bash
424
+ lemonade serve qwen2.5-it-3b-FLM
425
+ ```
426
+
427
+ 2. **Check URL:**
428
+ ```bash
429
+ echo %LEMONADE_SERVER_URL%
430
+ # Should be: http://localhost:8020
431
+ ```
432
+
433
+ 3. **Test connection:**
434
+ ```bash
435
+ curl http://localhost:8020/api/v1/chat/completions ^
436
+ -H "Content-Type: application/json" ^
437
+ -d "{\"model\": \"qwen2.5-it-3b-FLM\", \"messages\": [{\"role\": \"user\", \"content\": \"Hi\"}]}"
438
+ ```
439
+
440
+ ### Hooks Not Executing
441
+
442
+ **Error:** Commit message not generated
443
+
444
+ **Solutions:**
445
+
446
+ 1. **Check hooks path:**
447
+ ```bash
448
+ git config --global core.hooksPath
449
+ ```
450
+
451
+ 2. **Verify hook files exist:**
452
+ ```bash
453
+ dir %USERPROFILE%\.diffron-hooks
454
+ ```
455
+
456
+ 3. **Reinstall hooks:**
457
+ ```bash
458
+ python -c "from diffron.git_hooks import install_hooks; install_hooks(global_install=True)"
459
+ ```
460
+
461
+ ### Model Not Found (404 Error)
462
+
463
+ **Error:** `NotFoundError: Error code: 404`
464
+
465
+ **Solutions:**
466
+
467
+ 1. **Verify model is downloaded:**
468
+ ```bash
469
+ lemonade list
470
+ ```
471
+
472
+ 2. **Download model if missing:**
473
+ ```bash
474
+ lemonade pull qwen2.5-it-3b-FLM
475
+ ```
476
+
477
+ 3. **Set correct model name:**
478
+ ```cmd
479
+ setx DIFFRON_MODEL "qwen2.5-it-3b-FLM"
480
+ ```
481
+
482
+ ### Python Not Found
483
+
484
+ **Error:** `'python' is not recognized`
485
+
486
+ **Solutions:**
487
+
488
+ 1. **Add Python to PATH:**
489
+ - System Properties → Environment Variables
490
+ - Edit "Path" variable
491
+ - Add: `C:\Users\YourName\AppData\Local\Programs\Python\Python314\`
492
+ - Add: `C:\Users\YourName\AppData\Local\Programs\Python\Python314\Scripts\`
493
+
494
+ 2. **Use full path:**
495
+ ```bash
496
+ C:\Python314\python.exe -c "from diffron.git_hooks import install_hooks; install_hooks(global_install=True)"
497
+ ```
498
+
499
+ ---
500
+
501
+ ## Uninstall
502
+
503
+ ### Remove Hooks
504
+
505
+ ```bash
506
+ # Remove global hooks
507
+ python -c "from diffron.git_hooks import uninstall_hooks; uninstall_hooks(global_install=True)"
508
+ ```
509
+
510
+ ### Remove Environment Variables
511
+
512
+ 1. System Properties → Environment Variables
513
+ 2. Delete `LEMONADE_SERVER_URL` and `DIFFRON_MODEL`
514
+
515
+ ### Uninstall Package
516
+
517
+ ```bash
518
+ pip uninstall diffron
519
+ ```
520
+
521
+ ---
522
+
523
+ *Last updated: 2026-03-28*
524
+ *Version: 0.1.0*