Skip to content

About

Lightweight, Local-First AI Agent Workbench UI powered by WebGPU (WebLLM) and Ollama. 100% in-browser, zero backend required.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

LocalAgent-UI Logo LocalAgent-UI

Lightweight, Local-First AI Agent Workbench UI powered by WebGPU (WebLLM) and Ollama. Zero backend dependencies required.

中文 | GitHub Repo

LocalAgent-UI is a modern, high-performance in-browser AI Agent studio. It brings a native-like DevTools experience for visual Chain-of-Thought (CoT) reasoning, interactive Tool Calling visualization, and isolated client-side live code sandboxes directly inside your browser.

LocalAgent-UI Banner


🎬 Live Demo

WebGPU

LocalAgent-UI WebGPU demonstration

Ollama

LocalAgent-UI Ollama demonstration


✨ Key Highlights

  • 🧠 Visual Chain of Thought (CoT): Automatically parses <think>...</think> streaming tags into collapsible, high-tech reasoning cards (ThoughtAccordion).
  • 🛠️ In-Browser Tool Calling Loop: Supports autonomous function execution (Calculator, Weather API, Web Sandbox) with client-side user confirmation safety controls (Confirmation required).
  • 🔧 Built-in Frontend Tools: get_current_weather retrieves live conditions from Open-Meteo, calculator evaluates arithmetic with exact rational decimal inputs, and web_search provides an explicitly simulated result when no search service is configured.
  • 🛡️ Tool Execution Controls: Enable Confirm tool execution to approve or reject calls from their cards. Calls have a 10-second timeout, errors are returned to the model, and an eight-round limit prevents endless tool loops.
  • ⚡ Client-Side Live Code Sandbox: Renders generated HTML, SVG, CSS, and JS in an isolated iframe (CodeArtifactBox) with 1-click fullscreen preview and auto-merging for fragmented LLM outputs.
  • 🔌 Hybrid Provider Architecture:
    • In-Browser WebGPU: Runs 100% local, zero-backend LLMs (via @mlc-ai/web-llm in WebWorker).
    • Ollama REST API: Connects to local Ollama endpoints with dynamic health checks and auto-discovery of pulled models.
  • 📚 Local-First RAG: Import PDF or TXT files, extract text and split it into overlapping chunks in the browser, then generate embeddings in a Web Worker with Xenova/bge-small-zh-v1.5. Documents and vectors stay in IndexedDB; the top three matching excerpts are added to the system prompt before either provider runs. The embedding model is downloaded on first use and cached by Transformers.js.
  • 🎭 Prompt Presets & Session Settings: Includes Code Assistant, Translator, and Custom Agent prompts; create, edit, delete, and reuse custom presets across sessions. Engine, model, and prompt selection are stored per session in IndexedDB.
  • 📦 Session Backup & Restore: Export all sessions, chat histories, and custom prompt presets to a single JSON backup. Imports append records without overwriting local data and also support legacy single-session JSON exports.
  • 📝 Rich Markdown: Syntax-highlighted code, KaTeX math, and Mermaid diagrams render locally in the browser.
  • 🔒 Local-First Data Privacy: Sessions, model settings, system prompts, and chat histories are stored in your browser's IndexedDB (via Dexie.js). WebGPU inference runs in-browser, while Ollama requests go to your local Ollama service. The weather tool sends the requested city to Open-Meteo for live data; web_search is simulated and does not query a search provider. Streaming replies are periodically saved so partial output can be recovered after a reload.
  • 💨 Anti-Jank Stream Pipeline: Engineered with Zustand state buffering and RAF-throttled smart auto-scrolling for high-frequency token streams without UI jitter.

🛠️ Tech Stack

  • Framework: React 19 + Vite + TypeScript
  • Styling: Tailwind CSS + Lucide Icons + Custom Modern Scrollbars
  • State & DB: Zustand + Dexie.js (IndexedDB)
  • Inference Engines: @mlc-ai/web-llm (WebGPU) & Ollama REST Endpoint
  • Markdown & Syntax: React-Markdown, highlight.js, KaTeX, and Mermaid
  • Tests: Vitest + fake-indexeddb (npm test)

🚀 Quick Start

# Clone the repository
git clone https://github.com/real-rain/LocalAgent-UI.git

# Install dependencies
npm install

# Start local dev server
npm run dev

🔧 Trying Agent Tool Calls

Select a model, start a conversation, and send one of these prompts. When Confirm tool execution is enabled, approve the call from its tool card.

Tool Name (工具名称) Purpose (作用) Example Prompt (测试提示词)
Calculator High-precision math operations "Use the calculator tool to compute the exact result of 98765 * 43210."
Weather API Fetch live Open-Meteo data (mock data is returned if the service is unavailable) "Check the current weather in Beijing and show me the data returned by the tool."
Web Sandbox Generate and render frontend code "Create a 3D flip card with HTML/CSS/JS and preview it in the sandbox."

🏗️ Tool Calling Architecture / Flow

LLM Stream ➔ StreamParser (Detect Tool Call) ➔ User Confirmation (Optional) ➔ Browser JS Execution ➔ Feedback Tool Result to Context ➔ Final LLM Response

⚙️ Local Ollama CORS Setup Guide

When accessing LocalAgent-UI from a hosted web domain (e.g., Vercel / GitHub Pages), your browser will block requests to local Ollama (http://localhost:11434) due to CORS policies unless OLLAMA_ORIGINS is configured.

🪟 Windows (Recommended)

  1. Press Win + R, type sysdm.cpl, and press Enter.
  2. Go to Advanced tab -> Click Environment Variables.
  3. Under User variables, click New:
    • Variable name: OLLAMA_ORIGINS
    • Variable value: *
  4. Click OK to save.
  5. Right-click the Ollama icon in the system tray and select Quit Ollama, then re-launch Ollama from the Start Menu.

(Or run in PowerShell as Administrator once: [System.Environment]::SetEnvironmentVariable('OLLAMA_ORIGINS', '*', 'User'))


🍎 macOS / Linux

Run Ollama with the OLLAMA_ORIGINS environment variable in your terminal:

OLLAMA_ORIGINS="*" ollama serve

📬 Author & Community

Created with ❤️ by ☔@real-rain

Contact / Email: 1936648485@qq.com

About

Lightweight, Local-First AI Agent Workbench UI powered by WebGPU (WebLLM) and Ollama. 100% in-browser, zero backend required.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages