DEV Community

Nikita Gupta
Nikita Gupta

Posted on

How I Built a Lightweight Local AI Assistant (Python + PyQt6 + Ollama)

I built a fast, privacy focused desktop assistant by keeping the architecture modular and lightweight.

The Tech Stack
->Python & PyQt6 (Frontend UI and Screen Capture)
->Ollama API (Local LLM Backend)
->PyInstaller (Standalone Packaging)

Why Decouple the UI from Ollama?
Instead of embedding a multi-gigabyte model file directly into the application, I used a client-server split.

Lightweight Executable: The desktop app stays tiny because Ollama handles the heavy model inference externally in the background.

Resource Efficiency: System RAM and VRAM are managed dynamically by the operating system rather than choking a single monolithic process.

Solving the Windows DPI Scaling
A core feature is a custom screen-snipping tool. However, Windows DPI virtualization often desyncs logical mouse coordinates from physical screen pixels, causing cropped selections to pull from completely wrong areas.

Instead of relying on flaky operating system scaling multipliers, I bypassed the issue using direct dynamic ratio calculations, Capture the raw full-screen image first.

Calculate the exact mathematical ratio between the physical image size and the widget size.
Multiply the user's selection coordinates by that ratio to crop exact physical pixels cleanly.

Packaging It Up
By separating the UI and application logic from the raw model weights, compiling a clean, portable standalone .exe using PyInstaller takes seconds and avoids massive build file sizes.

Keeping your AI engine external isn't just easier to build, it is a cleaner, more scalable architecture for local desktop software.

Top comments (0)