How I created a local LLM (like Copilot but at the OS level) for text editing on my PC
Rather than paying for text editors' built-in AIs, I figured I'd try creating one myself, that can run in any program on my PC.
This is how I installed Ollama, set up a task-specific AI model, and integrated it with AutoHotkey (AHK) so I can highlight text in any app, press a keyboard shortcut, and instantly replace it with AI-generated modifications.
Gonna try to keep it super concise. Let me know if you have any questions.
🛠 Step 1: Install Ollama (local AI model runner)
Ollama lets you run AI models entirely offline.
Download and install Ollama. (I followed the installation instructions for Windows.)
Open the Command Prompt (
Win + R
, typedcmd
, hit Enter).Verify Ollama iss installed by running:
ollama
(If Ollama is installed correctly, it will display a help message.)
📥 Step 2: Install Mistral AI model
Mistral is a powerful lightweight AI model that runs locally.
I downloaded Mistral by running:
ollama pull mistral
This downloaded the model so it could be used offline.
I tested the model to make sure it was working:
ollama run mistral "Summarize this: Pipelines for computing experimental results include several key components."
As everything was working, the AI returned a shortened version of the sentence.
🤖 Step 3: Create a task-specific model (taskbot
)
By default, AI models tend to be conversational, returning strings like “Here’s the text you asked for:” or “Here are multiple options.” I modified the system prompt so it strictly follows instructions without unnecessary explanations.
A “task bot,” so to speak.
1️⃣ Create a directory for custom models
In Command Prompt, I ran:
mkdir C:\ollama_models
cd C:\ollama_models
2️⃣ Create a Modelfile
Create a file that told Ollama to modify Mistral’s behavior.
Open Notepad using:
notepad C:\ollama_models\Modelfile
Paste the following inside:
FROM mistral
SYSTEM "You are an AI assistant that strictly follows instructions. Your responses must contain only the requested transformation—no explanations, no alternative phrasings, and no unnecessary context."
Save and close Notepad.
Make sure the file name was exactly
Modelfile.
3️⃣ Create the custom model
I ran the following command to create the file in the specified location:
cd C:\ollama_models
ollama create taskbot -f Modelfile
Once completed, it said "Success" after creating new layers.
Nice!
4️⃣ Test the new model
I ran:
ollama run taskbot "Shorten this: Pipelines for computing experimental results include several key components."
This returned only the transformed output (e.g., "Experimental pipelines have key components.") without extra explanations.
⌨ Step 4: Set up AutoHotkey for instant AI text editing
AutoHotkey (AHK) lets me highlight text, press a shortcut, and instantly replace the text with AI-generated output—which is the specific functionality I wanted, since I already have ChatGPT for bigger problems.
1️⃣ Install AutoHotkey
I downloaded and installed AutoHotkey v2. Simple. I also explored other options but this got me up and running the fastest.
2️⃣ Create an AHK script
I opened Notepad and pasted the following:
^+e:: ; Ctrl + Shift + E to trigger AI replacement
Clipboard := "" ; Ensure clipboard is empty
Send, ^c ; Copy selected text
ClipWait, 1
if (Clipboard = "") {
MsgBox, Error: No text selected or unable to copy.
return
}
; Prompt user for instruction
InputBox, UserPrompt, AI Instruction, Enter your prompt (e.g., "Summarize this"), , 400, 150
if (ErrorLevel) ; If user cancels, exit
return
; Use only the copied text
SelectedText := Clipboard
FullPrompt := UserPrompt . ": " . SelectedText
; Send request to AI
Response := RunOllama(FullPrompt)
; Extract and clean AI response
CleanResponse := ExtractAIResponse(Response)
if (CleanResponse = "") {
MsgBox, Error: Failed to retrieve AI response.
return
}
; Replace selected text with AI response
Clipboard := CleanResponse
Send, ^v ; Paste AI response over the original text
return
RunOllama(PromptText) {
ReqBody := "{""model"":""taskbot"",""prompt"":""" . PromptText . """, ""stream"": false}"
URL := "http://localhost:11434/api/generate"
HTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
HTTP.Open("POST", URL, false)
HTTP.SetRequestHeader("Content-Type", "application/json")
HTTP.Send(ReqBody)
HTTP.WaitForResponse()
return HTTP.ResponseText
}
ExtractAIResponse(JsonText) {
if RegExMatch(JsonText, """response"":""(.*?)""", Match)
return StrReplace(Match1, "\n", " ") ; Convert \n to spaces for inline responses
else
return ""
}
Save the file as
OllamaPrompt.ahk
(set "Save as type" to "All Files").Double-click
OllamaPrompt.ahk
to run it.Now it listens for
Ctrl + Shift + E.
🚀 Step 5: Test the AI shortcut
I highlighted some text in a Notion doc.
I pressed
Ctrl + Shift + E
.I entered the instructions “summarize this.”
After some thinking, AI’s response replaced the selected text.
🔄 Step 6: Auto-run the script on startup
To make AutoHotkey run automatically at startup:
I pressed
Win + R
, typed:
shell:startup
I moved
OllamaPrompt.ahk
into this folder.Now, it started automatically when Windows booted.
Note: You can also just drag and drop the file into your startup folder.
🎯 Recap: This setup achieves:
✅ AI-powered text editing in any app
✅ Works offline (no internet needed)
✅ Fast, one-key execution (Ctrl + Shift + E
)
✅ Custom AI model that strictly follows commands
✅ No unnecessary explanations from the AI
✅ Runs on startup automatically
🎉 Done! I hope this helps you build your own AI-powered text editor
With this setup, you can instantly modify text using AI in any app—completely offline and without unnecessary explanations. If you're looking for a way to streamline your writing workflow, I hope this guide helps you do the same.
If you have any questions, want to expand the automation, or fine-tune the AI further, feel free to reach out. 🚀
Special shoutout to my homie Matt Paige for giving me DIY AI projects and inspiration daily.
The other one I like is https://jan.ai which can give you an API to use like Ollama does.