Skip to content
Quilibrium-CommunityPublic

About

AI chatbot for Q&A on Quilibrium

Resources

Contributing

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

Quily Chat

A self-hosted RAG chatbot that answers questions about the Quilibrium protocol using official documentation, livestream transcriptions, community docs and Discord announcements. It ships as a web app plus a Discord bot.

Features

  • RAG-powered answers with source citations from official Quilibrium docs
  • Streaming responses with a choice of LLM providers
  • Free mode: the server's key can serve all users, so nobody has to bring their own (NEXT_PUBLIC_FREE_MODE)
  • Chutes OAuth as an optional sign-in that needs no API key
  • Bring your own key when free mode is off
  • Two-stage retrieval with Cohere or Cloudflare reranking (free tier available)
  • Auto-sync of docs from GitHub, Discord announcements, the tech tree and the ecosystem list
  • Discord bot (bot/) that answers mentions and posts a daily digest
  • Bot protection with Cloudflare Turnstile
  • Conversation history persisted in browser localStorage
  • Dark mode support
  • Mobile responsive design
  • QA evaluation harness for stress-testing response quality with LLM-as-judge

Quick Start

Prerequisites

  • Node.js 22+
  • Yarn 4 (run corepack enable; the version is pinned in package.json)
  • Supabase account (free tier works)
  • An LLM provider API key (see .env.example)
  • Chutes account (optional, for Sign in with Chutes)
  • GitHub token (for docs sync, no scopes needed)

1. Clone and Install

git clone https://github.com/Quilibrium-Community/quily.git
cd quily
corepack enable
yarn

2. Configure Environment

Copy .env.example to .env.local and fill in your values. .env.example is the full, commented list; the essentials are:

# Supabase (required)
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_KEY=your_service_role_key

# LLM provider key (required: used for embeddings and chat)
OPENROUTER_API_KEY=your_api_key

# Free mode (optional): serve all users with the server's key
# NEXT_PUBLIC_FREE_MODE=true

# Chutes OAuth (optional - enables Sign in with Chutes)
# CHUTES_OAUTH_CLIENT_ID=cid_xxx
# CHUTES_OAUTH_CLIENT_SECRET=csc_xxx
# CHUTES_OAUTH_SCOPES="openid profile chutes:invoke"
NEXT_PUBLIC_APP_URL=http://localhost:3000

# Reranking (optional, improves retrieval quality)
# COHERE_API_KEY=your_cohere_key

# GitHub (required for docs sync)
GITHUB_TOKEN=ghp_your_token_here

Get your keys:

  • Supabase → Dashboard → Settings → API
  • LLM provider key (required, see .env.example)
  • Chutes → Create account (optional, for OAuth sign-in)
  • Cohere (optional)
  • GitHub → Generate token (no scopes needed for public repos)

3. Set Up Supabase

Create a new Supabase project and run the schema from scripts/db/schema.sql in the SQL Editor.

The schema uses BGE-M3 embeddings (1024 dimensions). Ingestion generates them through the configured provider.

4. Sync and Ingest Documentation

# Sync docs from Quilibrium GitHub repo
yarn sync-docs:run

# Ingest into vector database
yarn ingest:run

5. Run Development Server

yarn dev

Open http://localhost:3000 and start chatting. With free mode off, configure a provider (API key or Chutes sign-in) in Settings first.


Documentation Management

The chatbot's knowledge comes from the ./docs folder. Documentation is organized into three categories:

1. Official docs (synced from GitHub, automated)

Official Quilibrium docs are synced from QuilibriumNetwork/docs into docs/quilibrium-official/. The folder is tracked in git (the daily workflow commits to it), but never edit it by hand: the next sync overwrites your changes.

# Check what would change
yarn sync-docs:status

# Sync latest docs
yarn sync-docs:run

# Force re-download everything
yarn sync-docs:force

2. Discord mirrors (synced automatically)

docs/discord/ holds announcements, dev updates, node updates and the general recap, pulled from Discord by yarn sync-discord:run. Also an automated mirror: do not edit by hand.

3. Custom docs (your uploads, COMMITTED)

Add your own content to docs/transcriptions/ or docs/custom/. These are version-controlled. docs/custom/auto/ is generated by the tech tree and ecosystem syncs, so leave it alone.

docs/
├── quilibrium-official/          ← Synced from GitHub (automated)
│   ├── api/ build/ discover/
│   ├── learn/ protocol/ run-node/
│   └── .sync-manifest.json
├── discord/                      ← Synced from Discord (automated)
│   ├── announcements/ dev-updates/
│   └── node-updates/ general-recap/
├── transcriptions/               ← Livestream and interview transcripts (committed)
│   └── 2024-06-19_quilibrium-web3-galaxy-brain-interview.md
└── custom/                       ← Community docs (committed)
    ├── Epochs-And-Frames.md
    └── auto/                     ← Generated (tech tree, ecosystem)

Supported File Types

Extension Type Notes
.md Markdown Frontmatter supported
.txt Plain text Good for transcriptions

Keeping the Knowledge Base Updated

Automated (recommended)

A GitHub Actions workflow runs daily at 06:00 UTC. It syncs official docs and Discord content, commits any changes, and re-ingests embeddings into Supabase. Other workflows in .github/workflows/:

Workflow What it does
sync-docs.yml Daily docs and Discord sync + RAG ingestion
sync-techtree.yml Weekly tech tree sync
sync-ecosystem.yml Weekly ecosystem project list sync
monthly-model-scout.yml Monthly report on cheaper or better models
supabase-keepalive.yml Keeps the free-tier Supabase project from pausing
ci.yml Install and typecheck (guards the toolchain)

To enable the daily sync, add these GitHub Secrets (Settings → Secrets and variables → Actions):

Secret Value from .env
SUPABASE_URL NEXT_PUBLIC_SUPABASE_URL
SUPABASE_SERVICE_KEY SUPABASE_SERVICE_ROLE_KEY
OPENROUTER_API_KEY OPENROUTER_API_KEY
PAT_TOKEN A token that can push to the repo
DISCORD_BOT_TOKEN, DISCORD_CHANNEL_IDS, DISCORD_GENERAL_CHANNEL_ID Only if you sync Discord content

You can also trigger it manually from the Actions tab → "Daily Docs Sync & RAG Ingestion" → "Run workflow".

Manual update

# One-command: sync + ingest
yarn sync-docs:ingest

# Or step by step:
yarn sync-docs:run    # Sync latest from GitHub
yarn ingest:run       # Update the RAG database (BGE-M3 embeddings)
yarn sync-discord:run # Optional: pull Discord content (needs DISCORD_BOT_TOKEN)

After deleting files

# Remove orphaned chunks from database
yarn ingest:clean

Check sync status

# GitHub sync status
yarn sync-docs:status

# Database sync status
yarn ingest:status

All Commands

Development

Command Description
yarn dev Start development server
yarn build Production build
yarn start Start production server
yarn typecheck TypeScript type checking
yarn doc:lint Lint knowledge base docs
yarn retrieval:check Retrieval regression check
yarn prod-logs / yarn prod-curl Production debugging helpers

Discord Bot

The bot lives in bot/ with its own package.json. From that folder: npm run dev, npm run build, npm run start. Set DISCORD_BOT_TOKEN, DISCORD_CLIENT_ID and DISCORD_CHANNEL_IDS (see .env.example).

Documentation Sync

Command Description
yarn sync-docs:status Check for remote changes
yarn sync-docs:run Sync docs from GitHub
yarn sync-docs:force Force re-download all
yarn sync-docs:ingest Sync + auto-ingest
yarn sync-docs:dry Preview without downloading
yarn sync-docs verify Verify local files match manifest
yarn sync-discord:run Sync Discord announcements and updates
yarn sync-techtree Sync the Quilibrium tech tree
yarn sync-ecosystem Sync the ecosystem project list

Ingestion

Command Description
yarn ingest:run Run ingestion pipeline (default)
yarn ingest:run-chutes Run ingestion via Chutes (legacy, opt-in)
yarn ingest:clean Ingest + remove orphaned chunks
yarn ingest:dry Preview without uploading
yarn ingest:status Show local vs database sync
yarn ingest:count Count chunks in database
yarn ingest clean Remove orphaned chunks only

QA Evaluation

Command Description
yarn eval:list List all test cases
yarn eval:run Run full evaluation suite (requires OPENROUTER_API_KEY)
yarn eval:smoke Run smoke tests only (a few quick tests)
yarn eval:broad Run the broad suite (53 cases) instead of the focused default (43)
yarn eval:run --no-judge Deterministic checks only (free)
yarn eval:report <path> Re-display a saved JSON report

The eval harness sends queries to the chat API, parses streaming responses, and evaluates quality using deterministic checks and an LLM judge (Claude Sonnet). Requires a running dev server (yarn dev). See .agents/docs/qa-evaluation-harness.md for full documentation.


Project Structure

├── app/
│   ├── api/
│   │   ├── chat/route.ts       # Streaming chat endpoint with RAG
│   │   ├── auth/               # Provider and Turnstile auth
│   │   ├── chutes/models/      # Chutes model discovery
│   │   └── debug/retrieve/     # Retrieval debugging endpoint
│   ├── about/ links/ search/ settings/   # Other pages
│   ├── layout.tsx              # Root layout with theme provider
│   └── page.tsx                # Main chat page
├── bot/                        # Discord bot (own package.json)
│   └── src/                    # handlers/ (mention, digest, stats) and services/
├── docs/                       # Documentation source
│   ├── quilibrium-official/    # ← Synced from GitHub (automated)
│   ├── discord/                # ← Synced from Discord (automated)
│   ├── transcriptions/         # ← Transcripts (committed)
│   └── custom/                 # ← Community docs (committed; auto/ is generated)
├── scripts/
│   ├── ingest/                 # Ingestion pipeline
│   │   ├── index.ts            # CLI orchestrator
│   │   ├── loader.ts           # Document loader (.md, .txt)
│   │   ├── chunker.ts          # Semantic chunking
│   │   ├── embedder.ts         # BGE-M3 embeddings (default)
│   │   ├── embedder-chutes.ts  # BGE-M3 embeddings (Chutes)
│   │   └── uploader.ts         # Supabase upload + cleanup
│   ├── sync-docs/              # GitHub sync system
│   │   ├── index.ts            # CLI orchestrator
│   │   ├── github.ts           # GitHub API client
│   │   ├── manifest.ts         # Sync state tracking
│   │   ├── diff.ts             # Change detection
│   │   └── sync.ts             # File sync execution
│   ├── eval/                   # QA evaluation harness
│   │   ├── index.ts            # CLI entry point
│   │   ├── test-suite-focused.yaml  # Default suite (43 cases)
│   │   ├── test-suite.yaml     # Broad suite (53 cases)
│   │   ├── runner.ts           # Test execution engine
│   │   ├── judge.ts            # LLM-as-judge
│   │   ├── stream-parser.ts    # AI SDK stream parser
│   │   └── reporter.ts         # Terminal + JSON reports
│   ├── sync-discord/           # Discord content sync and recaps
│   ├── sync-techtree.ts        # Tech tree sync
│   ├── sync-ecosystem.ts       # Ecosystem list sync
│   └── db/
│       └── schema.sql          # Supabase schema
├── src/
│   ├── components/
│   │   ├── chat/               # Chat UI components
│   │   ├── sidebar/            # Sidebar components
│   │   └── ui/                 # Shared UI components
│   ├── hooks/                  # Custom React hooks
│   ├── lib/
│   │   ├── rag/                # RAG retrieval, reranking, prompts
│   │   ├── chutes/             # Chutes helpers
│   │   ├── openrouter.ts       # Model definitions
│   │   └── supabase.ts         # Database client
│   └── stores/                 # Zustand state management
└── .agents/
    └── docs/                   # Internal documentation

Environment Variables

Variable Required Description
NEXT_PUBLIC_SUPABASE_URL Yes Supabase project URL
SUPABASE_SERVICE_ROLE_KEY Yes Service role key (server-side)
SUPABASE_URL Yes Supabase URL (for scripts)
SUPABASE_SERVICE_KEY Yes Service key (for scripts)
GITHUB_TOKEN Yes For docs sync (no scopes needed)
OPENROUTER_API_KEY Yes LLM provider key (embeddings and chat)
NEXT_PUBLIC_FREE_MODE No Serve all users with the server's key
CHUTES_OAUTH_CLIENT_ID No Chutes OAuth client ID (for Sign in with Chutes)
CHUTES_OAUTH_CLIENT_SECRET No Chutes OAuth client secret
CHUTES_API_KEY No Chutes model discovery (OAuth tokens cannot list models)
CHUTES_OAUTH_SCOPES No OAuth scopes (default: openid profile chutes:invoke)
NEXT_PUBLIC_APP_URL No Used to build OAuth redirect URL
CHUTES_OAUTH_REDIRECT_URI No Override redirect URL
CHUTES_IDP_BASE_URL No Override Chutes IDP base URL
CHUTES_DEFAULT_MODEL No Default Chutes LLM chute URL
NEXT_PUBLIC_CHUTES_DEFAULT_MODEL No Client default Chutes model
CHUTES_EMBEDDING_MODEL No Chutes embedding chute URL
COHERE_API_KEY No Enables reranking (paid, highest quality)
CLOUDFLARE_ACCOUNT_ID No Free reranking via Workers AI
CLOUDFLARE_API_TOKEN No Free reranking via Workers AI
NEXT_PUBLIC_TURNSTILE_SITE_KEY, TURNSTILE_SECRET_KEY No Cloudflare Turnstile bot protection
DISCORD_BOT_TOKEN, DISCORD_CLIENT_ID, DISCORD_CHANNEL_IDS Bot only Discord bot and Discord sync
DEBUG_BYPASS_TOKEN No Lets yarn prod-curl debug production

See .env.example for the full list, including latency tuning and daily digest settings.


Tech Stack

  • Framework: Next.js 16 (App Router)
  • Styling: Tailwind CSS 4
  • State: Zustand + localStorage
  • AI: Vercel AI SDK with multiple provider options
  • Embeddings: BGE-M3 (1024 dimensions)
  • Vector DB: Supabase pgvector
  • Reranking: Cohere (paid) or Cloudflare Workers AI (free)
  • Bot protection: Cloudflare Turnstile
  • Discord bot: discord.js (in bot/)

Deployment

Quily is a standard Next.js app, so it runs on any host that supports Next.js (or on your own server with yarn build && yarn start).

  1. Push to GitHub
  2. Connect the repo to your host
  3. Add environment variables
  4. Deploy

Maintenance Guide

Daily sync (automated)

Documentation sync runs automatically via GitHub Actions. Check the Actions tab for run history and status. To trigger manually:

# Or run locally:
yarn sync-docs:ingest

After removing outdated content

# Delete files from ./docs, then:
yarn ingest:clean

Full refresh (if something seems wrong)

yarn sync-docs:force
yarn ingest:clean

Adding new transcriptions

  1. Add .txt or .md files to ./docs/transcriptions/ or ./docs/custom/
  2. Run yarn ingest:run

Troubleshooting

Issue Solution
Sync rate limited Add GITHUB_TOKEN to .env
Deleted files still in search Run yarn ingest:clean
Embeddings failing Check OPENROUTER_API_KEY (or CHUTES_API_KEY if you use yarn ingest:run-chutes)
Poor search results Add COHERE_API_KEY for reranking

For detailed documentation, see .agents/docs/rag-knowledge-base-workflow.md.


Related


Contributing

Help Improve Quily's Knowledge

Quily's answers are only as good as its knowledge base. If you notice something wrong or missing, there are two easy ways to help:

Option 1: Open a GitHub Issue (easiest)

  1. Go to Issues and click "New Issue"
  2. Select the "Knowledge Update" template
  3. Describe what Quily should know (or what it gets wrong)
  4. The maintainers will review and apply the change

Option 2: Submit a Pull Request

  1. Fork this repository
  2. Add or edit a .md file in docs/custom/
  3. Submit a PR — the maintainers will review, merge, and reingest

Note: Do not edit docs/quilibrium-official/ or docs/discord/ — these are automated mirrors and get overwritten.

Code Contributions

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

License

AGPL-3.0 license


Last updated: 2026-11-17

About

AI chatbot for Q&A on Quilibrium

Resources

Contributing

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages