# Local AI Stack — Windows Edition

A complete local AI tutor running on your Windows 10 or 11 PC. No Docker,
no cloud, no internet needed after setup. Four pieces, in order of how
deeply they "teach" the model:

1. **System prompt** (Modelfile) — instructions baked into the model's
   identity.
2. **LlamaIndex on your notes** — the model can look up your own files.
3. **LlamaIndex on Karpathy's blog** — same trick, bigger library.
4. **Hermes agent** — the model can use tools (calculator, files, dates).

## Quick start

Open **PowerShell** (right-click the Start button → Terminal or Windows
PowerShell), then:

```powershell
cd $env:USERPROFILE\Downloads\windows_stack
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force
.\setup_windows.ps1
```

The script may stop and ask you to close + reopen PowerShell after
installing Git, Ollama, or Python (so `PATH` refreshes). When that
happens, just close the window, open a fresh one, `cd` back, and run
`.\setup_windows.ps1` again. It will pick up where it left off.

## Files in this folder

| File | What it is |
| --- | --- |
| `Modelfile` | The "in the bones" system prompt for `kru-ai` |
| `requirements.txt` | Python packages: `llama-index` + Ollama plug-ins |
| `tutor.py` | RAG over your own `notes\` folder |
| `karpathy_tutor.py` | RAG over `karpathy_blog\_posts\`, with saved index |
| `agent.py` | Hermes 3 + four tools (multiply, divide, dates, read-notes) |
| `setup_windows.ps1` | Installs everything in one go |

## Try it

After the script finishes:

```powershell
# 1. Talk to the system-prompt-baked tutor
ollama run kru-ai

# 2. Ask questions about your own notes
.\.venv\Scripts\Activate.ps1
python tutor.py

# 3. Ask questions about Karpathy's writing
python karpathy_tutor.py

# 4. Watch an agent decide which tool to use
python agent.py
```

## When things go wrong

- **`.\setup_windows.ps1 : File ... cannot be loaded because running
  scripts is disabled`** — run `Set-ExecutionPolicy -Scope Process
  -ExecutionPolicy Bypass -Force` in the same window first, then re-run.
- **`ollama : The term 'ollama' is not recognized`** — Ollama installed
  but the system tray app isn't running. Open Ollama from the Start menu
  once, then close and reopen PowerShell.
- **First Karpathy index takes forever** — that's normal, ~5–10 minutes
  on Windows. The second run is instant because the index is saved to
  disk. Delete the `karpathy_index\` folder to re-index from scratch.
- **`pip install` fails with SSL or proxy errors** — if you're on a
  school/work network, ask IT for the proxy host or try a different
  network.
- **GPU not used / models feel slow** — Ollama on Windows uses CPU by
  default unless you have a CUDA-capable NVIDIA GPU with the right
  drivers. Try the smaller `llama3.2:1b` model if responses crawl.

## What each piece teaches you

- **Modelfile** teaches *identity and tone*. Cheap, instant, but the
  model still doesn't *know* anything new.
- **LlamaIndex** teaches *retrieval* — the model never memorises your
  notes, it looks them up at question-time. That's why it can cite
  exactly which file the answer came from.
- **Karpathy corpus** is the same trick at scale — proves RAG works on
  any folder of markdown.
- **Hermes agent** teaches *action*. The model can now affect the
  world (read files, do math) instead of only producing text.
