π§ Meet TalkLLM β A Local AI Assistant in React
Over the weekend, I built TalkLLM β a minimal, privacy-focused AI chat app that runs directly in the browser using WebLLM.
It uses Metaβs Llama 3 model via MLC AIβs WebLLM engine β meaning you get:
β Fast, local response generation
π‘οΈ Full privacy (no API keys, no cloud)
β‘ A smooth chat interface with history, loading state, and error handling
π οΈ What is WebLLM?
WebLLM lets you run large language models in-browser using WebGPU + WebAssembly β no servers or Python required.
Itβs powered by MLC, a powerful compiler stack for machine learning models. WebLLM brings that to your frontend.
You just need a compatible browser, and you can run powerful models like Llama 2/3, Phi, or Mistral β completely client-side.
βοΈ Tech Stack
React (with hooks)
@mlc-ai/web-llm
Llama 3.1 8B Instruct
Sass for lightweight styling
π¦ Project Setup
π GitHub Repo: https://github.com/mahmud-r-farhan/TalkLLM
π₯οΈ Requirements
-
β A WebGPU-compatible browser
- Chrome (v113+), Edge, Safari (macOS), or Brave
- π Test your browser here
β WebAssembly support
β Node.js v16+
β npm or yarn
π Installation
git clone https://github.com/mahmud-r-farhan/TalkLLM
cd TalkLLM
npm install
npm run dev
The app will run locally at http://localhost:5173
.
π Key Features in the Code
Local model initialization using
CreateMLCEngine()
Loading indicators during model setup and generation
Clean
useCallback()
-wrappedsendMessageToLlm()
functionInput validation (no empty prompts)
UI blocking during loading states
π§ Chat Memory Example
const [messages, setMessages] = useState([
{ role: "system", content: "Hello, I am TalkLLM. How can I assist you today?" }
]);
The model keeps context using a messages
array, just like the OpenAI API format.
π§ͺ Bonus: Want to Use a Different Model?
WebLLM supports multiple models. To switch, update this line:
const selectedModel = "Llama-3.1-8B-Instruct-q4f32_1-MLC";
Check out the model catalog for available variants.
πββοΈ Why Build This?
I wanted a way to explore LLMs without vendor lock-in. And with WebGPU maturing, it felt like the perfect time to experiment with truly local AI.
This app is a proof-of-concept β and a great starting point if youβre building privacy-first AI tools or offline chat experiences.
π Resources
π Final Thoughts
WebLLM is changing the game. Whether you're working on privacy-focused apps, internal tools, or want to tinker with LLMs β this opens up huge opportunities.
Follow for more!
Top comments (0)