Skip to content

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Offline LLM Chat + ๐Ÿ‘พ AI Overlord

Run a real LLM 100% inside your browser โ€” free, private, and fully offline after the first load. No server, no API key, no install. Includes a chat app and an arcade game where the AI is the villain.

Built with WebLLM (WebGPU) and wllama (llama.cpp โ†’ WASM, CPU) โ€” automatic fallback, so it works on any modern browser, with or without a GPU.

๐Ÿ’ฌ Chat ๐Ÿ‘พ AI Overlord
Chat with an offline LLM AI Overlord โ€” LLM-directed space shooter

โœจ What's inside

Page What it does
index.html ๐Ÿ’ฌ Minimal chat UI with streaming replies
game.html ๐Ÿ‘พ AI Overlord โ€” a canvas space shooter where the LLM designs every enemy wave live (count, speed, attack pattern, taunt) and gloats when you die
engine.js Shared loader: probes for a real WebGPU adapter โ†’ WebLLM; otherwise llama.cpp WASM on CPU
sw.js Service worker so the app shell works offline (models are cached by the engines themselves)

๐Ÿง  Models (free, Apache 2.0)

Model Size (Q4) Best for
SmolLM2-360M-Instruct ~260MB Fast replies, low-end machines
Qwen2.5-1.5B-Instruct ~1GB Noticeably smarter chat

Weights download once from Hugging Face, then live in browser storage (Cache API / IndexedDB) โ€” turn off wifi and everything keeps working.

๐Ÿš€ Quick start

git clone https://github.com/oyekamal/offline-llm-chat.git
cd offline-llm-chat
python3 -m http.server 8787   # any static server works (service workers need localhost or https)

Open http://localhost:8787 โ†’ pick a model โ†’ Load model โ†’ chat. Or open http://localhost:8787/game.html โ†’ Load AI โ†’ Start game.

๐ŸŽฎ How the game uses the LLM (design notes)

Small models are slow (seconds per reply on CPU) and unreliable (they ignore "reply with JSON only" half the time). The game is designed around that:

  • JS owns all game state โ€” the model can never break a round
  • The next wave is generated while you fight the current one โ€” latency is hidden, you never wait
  • Lenient parsing โ€” strict JSON first, then regex field-scraping, then clamped defaults ("backup wave") if the model rambled
  • The model contributes creativity (wave design, taunts, game-over gloats), not correctness

This pattern โ€” LLM as content director, JS as referee โ€” is the useful takeaway for building on top of tiny in-browser models.

๐Ÿ–ฅ๏ธ Compatibility

  • With GPU (WebGPU): Chrome/Edge 113+, recent Firefox/Safari โ†’ fast (WebLLM, ~80% native speed)
  • Without GPU: any browser with WASM SIMD โ†’ slower but works (wllama, CPU). Force it with ?cpu in the URL
  • Keep models โ‰ค2GB: Firefox caps per-site storage at 2GB

๐Ÿ› ๏ธ Ideas to build on top

  • Chat history persistence (localStorage)
  • More game modes (LLM-generated boss fights, power-up descriptions)
  • Voice input via Web Speech API
  • PWA install prompt + proper icons
  • RAG over local files with transformers.js embeddings

๐Ÿ“„ License

MIT โ€” do whatever you want.


#webllm #wllama #llamacpp #webgpu #wasm #offline-ai #local-llm #browser-llm #smollm #qwen #no-server #privacy #ai-game

About

๐Ÿค– Free LLM chat + ๐Ÿ‘พ AI-powered arcade game, running 100% in your browser โ€” offline, private, no server, no API key (WebLLM/WebGPU + wllama/WASM fallback)

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages