This file captures non-obvious, repo-specific facts. It is not a tutorial.
- Never write code first. Explain logic, UX impact, and architectural approach in plain text before touching files.
- Present a conceptual plan and wait for human approval before editing anything.
- When presenting multiple approaches or design choices, explicitly list the advantages and disadvantages of each option so the user can make an informed decision.
- Define complex terms inline the first time you introduce them.
- Write clean, readable code expecting to explain every choice line-by-line.
- PyQt6 GUI, single-window. No menu bars, trays, or sub-windows.
- llama-cpp-python for local CPU inference via GGUF models.
- model_downloader.py — downloads GGUFs from Hugging Face (huggingface_hub) or arbitrary URLs.
- Vosk offline STT via
voice_worker.py(QThread + PyAudio). - No test/lint/typecheck frameworks (
pytest,ruff,mypy). - Only use packages from
requirements.txt.
python main.py—./models/directory auto-scanned for.gguffiles.python tst.py— headless inference check.- Linux and Windows desktop only.
ai_manager.py: GGUF load/inference viallama-cpp-pythonin background threads.model_downloader.py: I/O withhuggingface_hub/requests+ progress callbacks.voice_worker.py: extendsQThread.- Everything else:
threading.Thread(daemon=True)— GIL serializes Qt calls, leave as-is. Llama()init is blocking (1-3s). Always run off-main-thread with a loading indicator.
- Models =
*.gguffiles in./models/. - Quantization parsed from filename (convention:
ModelName-Quant.gguf). set_model()skips validation. If GGUF not loaded,query_ai()loads it.- Display:
"{name} ({quant}, {size_gb} GB)".
- RAM detected via
psutil.virtual_memory().total(with platform fallback). model_budget = total_ram - max(1.5, total_ram * 0.2).- Priority among fitting GGUFs: Llama 3.2 → Phi-3 → Qwen 2.5 → TinyLlama → Mistral → smallest.
- Prefer highest quantization fitting within budget.
- UI shows budget, best-fit, and warns on over-budget selection.
- Empty state: No GGUFs in
./models/→ plain-language message ("No brain files found") + "Download Models" button or copy-paste HF link. - Timeouts: generation=120s, download=600s.
- Audio:
ALSA_LOG_LEVEL=0invoice_worker.py.
- Vosk model binary (~15MB) was committed then removed. Do not re-add.
- 5 commits, conventional short messages.