This repository contains the code to build and run a local AI agent directly in your browser. The agent leverages on-device AI capabilities, allowing it to interact with your local files securely and privately.
Important
This requires Chrome Canary or Edge Dev with the following flags enabled.
Try it here: https://ai.ryanseddon.com/build-local-agent/
Setup Instructions
- **Install Chrome Canary**: Ensure you have version 141. [Download Chrome Canary](https://google.com/chrome/canary/).
- Check that you’re on 141.0.7362.0 or above
- Enable two flags:
- chrome://flags/#optimization-guide-on-device-model - BypassPerfRequirement
- chrome://flags/#prompt-api-for-gemini-nano - Enabled
- Relaunch Chrome
- Navigate to chrome://components
- Check that Optimization Guide On Device Model is downloading or force download if not Might take a few minutes for this component to even appear
- Open dev tools and type `(await LanguageModel.capabilities()).available`, should return "readily" when all good
- If not you can trigger the download by doing the follow: ```const session = await LanguageModel.create({monitor(m) {m.addEventListener("downloadprogress", e => { console.log(`Downloaded \${e.loaded} of \${e.total} bytes.`); });}});```
This is an attempt to get the How to Build an Agent article working in the browser using the Gemini Nano and Phi-4-mini in Chrome and Edge respectively.
Read the How to build an Agent, On-Device Edition.
-
Prerequisites: You will need a browser that supports the Web AI API, such as a recent version of Google Chrome Canary or Microsoft Edge Dev.
-
Installation:
npm install
-
Build:
npm run build
-
Run: Open the
index.htmlfile in your browser. -
Open: Open the devtools console (F12) to see the agent output.
-
Start Agent: Click the "Start Agent" button to begin interacting with the agent.
-
Grant Access: Click the "grant access to a directory" button when prompted by the agent.
