Skip to content

lemonade-sdk/LemonAIdeBot

Repository files navigation

LemonAIde

LemonAIde

AI-powered Discord bot that answers community questions using your docs, source code, and taught facts.

License Node.js 20+ discord.js v14


What It Does

  • Auto-answers questions — monitors channels and replies when @mentioned, with source citations
  • Hybrid RAG pipeline — vector search + keyword matching + LLM query expansion for high retrieval accuracy
  • Thread mode — replies in threads to keep channels clean (configurable: ephemeral / thread / inline)
  • Teach the bot — add facts, corrections, or domain knowledge via /lemonaidebot teach
  • Auto-discovers docs — fetches and indexes your repo's documentation on startup
  • Works with any LLM — any OpenAI-compatible server (Ollama, LM Studio, vLLM, llama.cpp, Lemonade, or cloud APIs)
  • Eval suite — 60-question test harness with LLM-as-judge grading to measure answer quality
  • Bring your own project — point it at any repo and docs site; not tied to a specific project

Quick Start

Prerequisites

  • Node.js 20+
  • A Discord botcreate one here
  • An LLM serverOllama, LM Studio, Lemonade, or any OpenAI-compatible endpoint
  • An embedding model — for vector search (e.g. nomic-embed-text)

1. Install

git clone https://github.com/your-org/lemonaidebot.git
cd lemonaidebot
npm install

2. Configure

cp .env.example .env
# Edit .env with your values
Variable Description Example
DISCORD_BOT_TOKEN Bot token from Discord Developer Portal MTQ5...
DISCORD_CLIENT_ID Application client ID 149691...
LLM_BASE_URL LLM server endpoint http://localhost:11434/v1
LLM_MODEL Chat model name qwen3:8b
LLM_PROVIDER API provider (openai for all local LLMs) openai
DATABASE_URL Database connection string file:./lemonaidebot.db
PROJECT_NAME Your project name (used in answers) My Project
DOCS_URL Documentation site URL https://docs.example.com
SOURCE_REPO_URL Source repository URL https://github.com/you/repo
EMBEDDING_MODEL Embedding model for vector search nomic-embed-text

See .env.example for the full list with documentation.

3. Set Up the Database

npm run db:push

4. Register Discord Slash Commands

npm run deploy-commands

5. Run

npm start
# or with auto-reload:
npm run dev

Discord bot permissions required: Send Messages, Read Message History, Add Reactions, Create Public Threads, Send Messages in Threads, Manage Threads

Commands

Command Description
/lemonaidebot help Show all commands
/lemonaidebot teach Teach the bot a new fact or correction
/lemonaidebot facts List all taught facts
/lemonaidebot forget Remove a taught fact
/lemonaidebot model View or switch the active LLM model
/lemonaidebot settings Configure reply mode and thread settings (admin)
/lemonaidebot cleanup Archive old bot threads
/lemonaidebot refresh Refresh docs from GitHub and rebuild knowledge base
/briefing channel Summarize recent activity in a channel
/briefing day Daily summary of what was resolved

How RAG Works

LemonAIde uses a hybrid retrieval-augmented generation pipeline. When a question comes in, the LLM generates alternate search queries, then both vector search and keyword search run in parallel. Results are merged with a 60/40 vector/keyword weighting, and the top chunks are injected into the system prompt for answer generation.

User asks a question
       │
       ▼
┌─────────────────┐
│  LLM Query      │──→ Generates 3 alternate search queries
│  Expansion      │
└────────┬────────┘
         │
    ┌────┴────┐
    ▼         ▼
┌────────┐ ┌────────┐
│ Vector │ │Keyword │──→ Searches with expanded query terms
│ Search │ │ Search │
└───┬────┘ └───┬────┘
    │          │
    ▼          ▼
┌─────────────────┐
│  Hybrid Merge   │──→ 60/40 vector/keyword weighting + tier boost
│  + Force-Include│──→ High-priority docs always available
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│  Top 12 Chunks  │──→ Injected into the system prompt
│  + Version Info │──→ Auto-extracted from repo
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│   LLM Answer    │──→ JSON response with answer + source links
│   Generation    │
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│  Post to Discord│──→ Ephemeral DM, thread, or inline reply
│  (configurable) │
└─────────────────┘

Eval Suite

npm run eval              # Full eval (60 questions)
npm run eval:quick        # Quick eval (5 questions)
npm run eval -- --tag "my-test"   # Tag a run for comparison

Results are saved to eval-results/ as JSON. Uses keyword matching as a fast first pass, then LLM-as-judge for semantic grading.

Project Structure

src/
  ai/              # LLM client, prompts, knowledge base, vector store
  commands/        # Discord slash commands
  db/              # Prisma database client
  discord/         # Embeds, buttons, modals, pagination
  engines/         # Scanner engine (RAG pipeline)
  models/          # Data models
  utils/           # Logger, time, dedup, sanitize
scripts/           # Eval runner, docs fetcher
prompts/           # Markdown prompt templates
prisma/            # Database schema
test/              # Vitest test suite

Configuration Reference

All settings are documented in .env.example. Admin settings (reply mode, thread archive time, active model) can be changed at runtime via /lemonaidebot settings without restarting.

Contributing

  1. Open an issue to discuss your idea before submitting a PR.
  2. Run npm test to make sure tests pass.
  3. PRs welcome — keep changes focused and include tests where applicable.

License

Apache License 2.0

About

AI-powered Discord bot that answers community questions using Lemonade docs, source code, and taught facts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors