Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 QueryBot

A lightweight, stateless RAG chatbot built with Gradio and a Notion page knowledge base, designed for simple and low-cost deployment.

Overview

This project provides a minimal RAG chatbot that answers questions using information retrieved from a Notion knowledge base.

The chatbot is stateless: each question is processed independently without appending conversation history to the LLM prompt. This reduces token usage and keeps inference costs low, making the architecture suitable for lightweight deployments and high-volume use cases.

Tech stack: Python · Gradio · Google Gemini · Notion · Supabase

Features

  • 🧠 RAG-powered answers — Retrieve relevant information from a Notion knowledge base
  • 💬 Simple chat interface — Lightweight Gradio front-end requiring minimal infrastructure
  • 💰 Low-cost architecture — Stateless queries minimise unnecessary LLM token usage
  • 📄 Notion knowledge base — Use an existing Notion page as the source of knowledge
  • 💾 Query persistence — Optionally store user questions in Supabase for analysis and evaluation
  • ⚙️ Configurable — Adapt the knowledge base, retrieval strategy and model to different applications
  • 🚀 Easy deployment — Suitable for lightweight cloud deployments such as Hugging Face Spaces

How It Works

User question
      ↓
Retrieve relevant knowledge
      ↓
Construct RAG prompt
      ↓
LLM generates answer
      ↓
Display response
      ↓
Optionally store question

Example

The chatbot can be adapted to a range of use cases, for example:

Hospitality

A hostel can provide a QR code allowing guests to ask questions about check-in, facilities, local recommendations and house rules.

Internal knowledge

A small organisation can provide employees with a low-cost interface for querying internal documentation.

Product information

A business can create a chatbot that answers customer questions using product documentation or FAQs.

Installation

git clone https://github.com/jcarterlab/<repository>.git
cd <repository>

python -m venv .venv
source .venv/bin/activate  # macOS/Linux or
.venv\Scripts\Activate.ps1  # Windows PowerShell

pip install -r requirements.txt
cp .env.example .env

Configure the required environment variables, then run:

python app.py

Configuration

Create a .env file and configure the knowledge base, LLM and retrieval settings.

Knowledge base

Provide the Notion API credentials and page ID:

NOTION_API_KEY=your_notion_api_key
NOTION_PAGE_ID=your_notion_page_id

LLM

Set your Gemini API key and model:

GEMINI_API_KEY=your_gemini_api_key
MODEL=gemini-2.5-flash-lite

USE_AI controls whether AI-assisted processing is enabled:

USE_AI=false

Retrieval

Configure the number of chunks retrieved and the retrieval method:

CHUNKS_USED=3
RETRIEVAL_METHOD=tfidf

Supported retrieval methods are tfidf, dense_embeddings and hybrid.

For hybrid retrieval, configure the relative weighting of TF-IDF and dense embeddings:

TFIDF_WEIGHT=0.3
DENSE_EMBEDDINGS_WEIGHT=0.7

Query storage

Set STORE_QUERIES=true to persist user questions in Supabase:

STORE_QUERIES=true
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_key

Query storage is optional and can be disabled by setting STORE_QUERIES=false.

Limitations

  • Retrieval quality: Answers depend on the quality of the retrieval strategy and underlying knowledge base.
  • LLM responses: The model may generate inaccurate or incomplete answers despite retrieved context.
  • Notion dependency: Changes to the knowledge base may require the application to refresh or reprocess its content.
  • Stateless conversations: The chatbot does not retain conversational context between questions.
  • API costs and limits: Although designed to minimise LLM usage, costs and rate limits still depend on query volume and the selected model.

Inspiration

This project was inspired by ChatSJB, a chatbot built for Saint James Backpackers in 2023 to help onboard new staff and volunteers.

ChatSJB used the hostel's 57-page operations manual as its knowledge base, allowing reception staff to ask questions about policies and procedures through a Gradio chatbot hosted on Hugging Face Spaces.

This project revisits the same idea. However, instead of a Word document that must be re-uploaded when changes are made, it makes API calls to a Notion page to update its knowledge while supporting a range of configurable retrieval strategies.

About

A lightweight, stateless RAG chatbot designed for low cost deployments using a Gradio frontend and Notion knowledge base.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages