Skip to content

alminisl/localLLMUi

Repository files navigation

πŸ€– Local LLM Chatbot with Swarm Mode

A powerful, privacy-focused chatbot that runs entirely on your machine

License: MIT Node.js LM Studio

Features β€’ Demo β€’ Installation β€’ Usage β€’ Swarm Mode


✨ Features

🎯 Core Features

  • 100% Local - All processing happens on your machine. No data sent to external servers (except optional web search)
  • Multi-Model Support - Load and switch between any models from LM Studio
  • Real-time Streaming - See responses generate word-by-word
  • Smart Web Search - Auto-detects when to search the web for current information
  • Source Citations - Every web search result includes clickable source links
  • Conversation Memory - Maintains context throughout your chat session

🐝 Swarm Mode (UNIQUE!)

  • Multi-Model Responses - Query multiple AI models simultaneously
  • Color-Coded Chat - Each model gets a unique color for easy identification
  • Group Chat Interface - Models respond together like a conversation
  • Flexible Selection - Choose which models participate in the swarm
  • Consensus Building - Compare different perspectives on the same question

🎨 User Interface

  • Modern React UI - Clean, responsive design with Tailwind CSS
  • Dark/Light Themes - (Customizable via Tailwind)
  • Model Selector - Easy dropdown to switch between loaded models
  • Connection Status - Real-time indicator for LM Studio connection
  • Mobile Responsive - Works great on any device

🎬 Demo

Single Model Mode

Ask questions and get intelligent responses powered by your local LLM:

You: What is quantum computing?
Bot: Quantum computing is a type of computing that uses quantum-mechanical
     phenomena...

Swarm Mode

Get multiple perspectives at once:

You: What's the best programming language for beginners?

πŸ”΅ Qwen-3: I'd recommend Python because of its readability...

🟣 Qwen-2.5: JavaScript is great for beginners since you can see results immediately...

🟒 Llama-3: Consider starting with Python for its extensive libraries...

Web Search

Automatic web search for current information:

You: What's the weather in Tokyo today?
πŸ” Searching the web...

Bot: According to current weather data [1], Tokyo is experiencing...

Sources:
[1] Weather.com - Tokyo Weather Forecast
[2] Japan Meteorological Agency - Current Conditions

πŸš€ Installation

Prerequisites

  1. Node.js (v16 or higher)

    node --version  # Should be 16.0.0 or higher
  2. LM Studio - Download here

    • Install LM Studio
    • Download at least one model (recommended: Phi-3, Qwen, or Llama)
  3. Brave Search API Key (Optional, for web search)

Setup Steps

  1. Clone the repository

    git clone https://github.com/yourusername/local-llm-chatbot.git
    cd local-llm-chatbot
  2. Install dependencies

    npm install
  3. Configure environment

    cp .env.example .env

    Edit .env and add your Brave API key (optional):

    BRAVE_API_KEY=your_brave_api_key_here
  4. Set up LM Studio

    • Open LM Studio
    • Go to "Discover" and download a model
    • Load the model in the "Chat" tab
    • Go to "Local Server" β†’ Click "Start Server"
    • Verify it's running on port 1234
  5. Test the connection

    npm run test:lm

    You should see:

    βœ… LM Studio is working correctly!
    
  6. Start the application

    npm run dev
  7. Open in browser

    http://localhost:5173
    

πŸ“– Usage

Basic Chat

  1. Select a model from the dropdown
  2. Type your question
  3. Press Send or hit Enter
  4. Watch the response stream in real-time

Enabling Web Search

The chatbot automatically searches the web when you ask about:

  • Current events, news, weather
  • Latest versions, prices, stock data
  • Real-time information
  • Recent facts

Example queries:

  • "What's the latest iPhone model?"
  • "Current price of Bitcoin"
  • "Weather in Paris today"

🐝 Swarm Mode

Activate Swarm Mode:

  1. Click the "🐝 Swarm ON" button in the header
  2. Select which models you want to participate
  3. Ask your question
  4. All selected models will respond with unique colors

Use Cases for Swarm Mode:

  • Compare perspectives - See how different models approach the same problem
  • Fact-checking - Cross-reference information across models
  • Creative brainstorming - Get diverse ideas from multiple AI personalities
  • Code review - Multiple models can spot different issues
  • Learning - See how different models explain concepts

πŸ› οΈ Configuration

Adding Custom Fonts

  1. Add font files to public/fonts/
  2. Update src/index.css:
    @font-face {
      font-family: 'YourFont';
      src: url('/fonts/YourFont.woff2') format('woff2');
    }
    body {
      font-family: 'YourFont', sans-serif;
    }

Changing Models

Simply load different models in LM Studio and they'll appear in the dropdown automatically!

Adjusting Temperature

Edit server.js line 109:

temperature: 0.3, // Lower = more focused, Higher = more creative

πŸ“ Project Structure

localLLM/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ App.jsx              # Main React component with Swarm Mode
β”‚   β”œβ”€β”€ main.jsx             # React entry point
β”‚   └── index.css            # Tailwind styles
β”œβ”€β”€ public/                  # Static assets
β”œβ”€β”€ server.js                # Express backend with multi-model support
β”œβ”€β”€ test-lmstudio.js         # LM Studio connection tester
β”œβ”€β”€ .env.example             # Environment variables template
β”œβ”€β”€ vite.config.js           # Vite configuration
β”œβ”€β”€ tailwind.config.js       # Tailwind CSS configuration
└── package.json             # Dependencies and scripts

🎯 API Endpoints

POST /api/chat

Send a message and receive streaming response

Request:

{
  "message": "Your question",
  "conversationId": "unique-id",
  "model": "qwen/qwen3-vl-4b",
  "swarmMode": false,
  "models": ["model1", "model2"]
}

Response: Server-Sent Events (SSE)

data: {"type":"status","status":"Analyzing query..."}
data: {"type":"content","content":"Response text...","modelId":"model-name"}
data: {"type":"sources","sources":[...]}
data: {"type":"done"}

GET /api/models

Get list of available models from LM Studio

Response:

{
  "models": [
    {"id": "qwen/qwen3-vl-4b", "name": "qwen3-vl-4b"},
    {"id": "qwen2.5-3b-instruct", "name": "qwen2.5-3b-instruct"}
  ]
}

GET /api/health

Check server and LM Studio connection status

POST /api/clear

Clear conversation history


🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ› Troubleshooting

LM Studio won't connect

  • Ensure LM Studio is running
  • Check that Local Server is started (port 1234)
  • Load a model in LM Studio
  • Run npm run test:lm to diagnose

Models not appearing

  • Make sure models are loaded in LM Studio (not just downloaded)
  • Restart the dev server
  • Check browser console for errors

Web search not working

  • Verify BRAVE_API_KEY in .env
  • Check free tier limits (2000 queries/month)
  • Web search is optional - chatbot works without it

Slow responses

  • Try smaller models (Phi-3, Qwen-2.5-3B)
  • Close other applications
  • Check CPU/GPU usage
  • Reduce context length in LM Studio settings

πŸ“ Scripts

npm run dev          # Start both backend and frontend
npm run dev:server   # Start backend only
npm run dev:client   # Start frontend only
npm run test:lm      # Test LM Studio connection
npm run build        # Build for production

πŸ”’ Privacy & Security

  • 100% Local Processing - Your conversations never leave your machine
  • No External APIs - Except optional Brave Search (can be disabled)
  • No Data Collection - We don't collect, store, or transmit your data
  • Open Source - Full transparency, inspect the code yourself

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments


🌟 Star History

If you find this project useful, please consider giving it a star!


Built with ❀️ for the local AI community

Report Bug β€’ Request Feature

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages