A simple Electron application that helps rewrite your clipboard content in different styles (polite, formal, short) using Ollama and Llama2. This is a toy project for learning and experimentation.
- Global Shortcut: Press
Cmd+Shift+A(Mac) orCtrl+Shift+A(Windows/Linux) to capture clipboard content - AI Rewriting: Automatically processes text using Ollama with Llama2 model
- Multiple Styles: Get suggestions in polite, formal, and short formats
- One-Click Replacement: Click any suggestion to replace your clipboard content
- System Tray: Runs in the background with system tray integration
- Node.js (v16 or higher)
- Python (v3.8 or higher)
- Poetry (Python dependency manager)
- Ollama with Llama2 model
# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Pull Llama2 model
ollama pull llama2# Clone the repository
git clone
cd lexi
# Install Electron dependencies
cd electron
npm install
# Install Python dependencies
cd ../backend
poetry installcd backend
poetry run fastapi run src/main.pyThe FastAPI server will start on http://localhost:8000
cd electron
npm run dev- Copy any text to your clipboard
- Press the global shortcut
Cmd+Shift+A(Mac) orCtrl+Shift+A(Windows/Linux) - Wait for AI processing - the app will show "Loading..." while processing
- Choose your preferred style:
- Polite: Rewritten in a polite, courteous manner
- Formal: Rewritten in a formal, professional tone
- Short: Rewritten in a concise, brief format
- Click any button to replace your clipboard with the chosen version
lexi/
├── electron/ # Electron frontend
│ ├── src/
│ │ ├── main/ # Main process
│ │ ├── preload/ # Preload scripts
│ │ └── renderer/ # React frontend
│ └── package.json
├── backend/ # FastAPI backend
│ ├── src/
│ │ └── main.py # FastAPI application
│ └── pyproject.toml # Poetry dependencies
└── README.md
# Build Electron app
cd electron
npm run build
# The built app will be in the dist/ folder-
"API Available: ❌" in Debug Info
- The preload script isn't loading properly
- Check the terminal for preload script errors
- Restart the Electron app
-
"No module named 'ollama'"
- Make sure Ollama is installed:
ollama --version - Ensure you're in the correct Poetry environment:
poetry shell
- Make sure Ollama is installed:
-
Global shortcut not working
- Check if the shortcut is registered in the terminal
- Try restarting the app
- On some systems, you may need to grant accessibility permissions
-
FastAPI connection errors
- Ensure the backend server is running on port 8000
- Check the Content Security Policy in
src/renderer/index.html
Enable debug logging by checking the browser console (F12) in the Electron window for detailed error messages.