Version 2.0 introduces browser-based AI inference using Transformers.js. This means:
- ✅ No Python backend required (by default)
- ✅ No Ollama installation needed (by default)
- ✅ Works out of the box - just install the extension
- ✅ Backward compatible - can still use Python backend if preferred
- Install the browser extension (see README.md for browser-specific instructions)
- Navigate to any webpage with code
- Hold Shift + drag to select code
- Wait for model to download on first use (~15-60 seconds)
- Subsequent uses are instant!
On your first use of the extension, it will:
- Download an AI model from Hugging Face CDN (~350MB)
- Cache the model in your browser's IndexedDB
- Initialize the model for inference
This only happens once. After the first download, the extension works offline and loads instantly.
- Chrome 113+
- Edge 113+
- Brave 1.52+
- Chrome 88+
- Firefox 118+
- Safari 16+
- Edge 88+
- All modern browsers
- 2GB+ RAM available
- 500MB+ free disk space (for model cache)
- Modern browser with WebGL support
The extension uses browser storage for:
- IndexedDB: Cached AI models (~350MB)
- Chrome Sync Storage: User settings (<1KB)
To clear cached models:
- Chrome: Settings → Privacy → Clear browsing data → "Hosted app data"
- Firefox: Settings → Privacy → Clear Data → "Offline Website Data"
- No installation beyond the extension
- AI runs in your browser using WebGPU/WebGL
- Fast on modern GPUs (2-5 seconds)
- Works offline after first model download
- Complete privacy (no network requests after download)
- Requires Python + Ollama installation
- Uses moondream:1.8b model via Ollama
- Slower than browser-based mode (8-12 seconds)
- Requires backend server running locally
To enable backend mode:
- Open extension options
- Change "Inference Mode" to "Backend Mode"
- Follow backend setup instructions below
If you choose to use backend mode:
- Install Ollama: https://ollama.ai
- Pull model:
ollama pull moondream:1.8b - Install Python deps:
pip install fastapi uvicorn pillow ollama python-multipart - Start backend:
python backend.py - Configure extension: Set backend URL in options (default: http://127.0.0.1:8000)
The browser_specific_settings.gecko.id field in manifest.json uses a placeholder value (learnbyhover@example.com).
The placeholder is fine for local testing and temporary add-ons.
You should replace it with:
- A valid email-style ID using a domain you control (e.g.,
extension@yourdomain.com) - OR follow Mozilla's UUID format:
{<UUID>}(e.g.,{12345678-1234-1234-1234-123456789abc})
Generate a UUID using:
uuidgen # On macOS/LinuxOr:
python3 -c "import uuid; print('{' + str(uuid.uuid4()) + '}')"Update the manifest.json with your chosen ID before publishing to addons.mozilla.org (AMO).
Safari extensions must be packaged within a macOS app. Use the safari-web-extension-converter tool as documented in the README.md file.
The browser-based AI works in Safari using WebGL acceleration (WebGPU support coming in future Safari versions).
- Check internet connection
- Try reloading the page
- Clear browser cache and retry
- Check available disk space (need 500MB+)
- Fallback: Enable backend mode in settings
- Close other tabs to free memory
- Try clearing browser cache
- Consider using backend mode instead
- Ensure WebGL is enabled in browser settings
- Update graphics drivers
- Try Chrome/Edge for WebGPU support
- Consider backend mode for very old hardware
- Check browser console for errors
- Verify extension permissions are granted
- Try reinstalling the extension
- Check browser version compatibility
If you're upgrading from version 1.0:
- No action required - extension will use browser mode by default
- Keep backend running if you want to use legacy mode
- Change setting to "Backend Mode" if you prefer the old behavior
- First use will download model (one-time, 15-60 seconds)
The model-worker.js file runs in a Web Worker thread to avoid blocking the UI. It:
- Loads Transformers.js from CDN
- Initializes vision-language models
- Processes images for code analysis
- Reports progress during download/initialization
The manifest includes 'wasm-unsafe-eval' in CSP to allow WebAssembly execution needed for Transformers.js.
The model-worker.js file is declared as a web accessible resource so it can be loaded as a module worker.