Skip to content

asish231/ClipLLM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 ClipLLM

A lightweight clipboard-to-Ollama bridge for macOS. Copy a prompt, get an AI response — right in your clipboard.

How It Works

  1. Copy text starting with //ollama (e.g., //ollama explain quantum physics)
  2. Wait a moment while ClipLLM sends your prompt to Ollama.
  3. Paste — the AI response is now in your clipboard!

Choose Your Version

You can run ClipLLM using either Python or Java. Both do the same thing, but have different setups.

Option A: Python Version

Best if you prefer working with scripts and the requests library.

Setup:

# Create a virtual environment and install dependencies
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Run:

source venv/bin/activate
python clipllm.py

☕ Option B: Java Version (Native & Fast)

Best for a "zero-dependency" experience. It uses pure Java 11+ features.

Setup: No installation needed! Just make sure you have a JDK installed.

Run:

# Compile and run in one step
java ClipLLM.java

📋 Prerequisites (For Both)

  • Ollama installed and running — ollama.com
  • Model pulled:
    ollama pull gemma4:e4b
    ollama pull nemotron-3-nano:4b
  • Ollama serving: Make sure the Ollama app is open or run ollama serve.

⚙️ Configuration

Variable Default Description
PRIMARY_MODEL gemma4:e4b The main high-quality model
FALLBACK_MODEL nemotron-3-nano:4b Faster model used if the primary fails
TRIGGER //ollama Text prefix that triggers a prompt
POLL_INTERVAL 500ms How often to check the clipboard

Technical Comparison

Feature Python Implementation Java Implementation
Clipboard subprocess -> pbpaste/pbcopy java.awt.Toolkit (Native API)
HTTP Client requests (External Lib) java.net.http.HttpClient (Native)
JSON Safety Manual String replace escapeJson() helper function
Concurrency time.sleep() Thread.sleep()
Dependencies 1 (requests) 0 (Zero!)

Why Java?

While the Python version is easy to write, the Java version is more powerful because it talks to the macOS system directly using the java.awt library, and it doesn't need any pip install to work.

What is the "Thread"?

Both versions use a Thread Sleep. This is crucial for your CPU's health. Instead of checking the clipboard millions of times per second (which would make your Mac hot), the program "naps" for 500ms between checks, keeping your CPU usage near 0%.


Troubleshooting

Problem Solution
"Cannot connect to Ollama" Run ollama serve or open the Ollama app.
"Model not found" Run ollama pull gemma4:e4b.
"Slow responses" The app will automatically try the Fallback model if it takes too long.
"Nothing happens" Ensure your copied text starts exactly with //ollama (with the space).

About

Promt LLM's with just copy command a bypass to few protected browser's and area's

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors