CoolFace
Apppublic

haham7/nbc-chatbot

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes
App README

NBC 2016 RAG Chatbot

AI-powered chatbot for the National Building Code of India 2016 (NBC 2016). Built with LangGraph, Qdrant, and Neo4j.

Features

  • —Hybrid Search: Dense + sparse vector search via Qdrant
  • —Multi-turn Conversation: LangGraph with 10-turn memory
  • —Guardrails: Off-topic detection for NBC-related queries
  • —Clause Citation: References NBC clauses in answers
  • —Graph Traversal: Neo4j for cross-reference expansion

Architecture

User → API → LangGraph Agent → Qdrant (vectors) + Neo4j (graph) → LLM → Response

Quick Start (Local)

bash
# Install dependencies
pip install -r requirements.txt

# Start services
docker compose up -d

# API at http://localhost:8000
# UI at http://localhost:8501

Cloud Deployment

Option 1: Render (Recommended)

  1. 1.Create accounts:
  2. 2.Render.com - Web service
  3. 3.Qdrant Cloud - Vector DB (free tier)
  4. 4.Neo4j Aura - Graph DB (free tier)
  1. 1.Get credentials:
  2. 2.Qdrant: API key + URL (e.g., https://xyz.qdrant.cloud)
  3. 3.Neo4j: Username + password + bolt URL
  1. 1.Deploy on Render:
  2. 2.Connect GitHub repo
  3. 3.Set environment variables:
     OPENAI_API_KEY=sk-...
     QDRANT_URL=https://xyz.qdrant.cloud
     NEO4J_URI=bolt://xyz.databases.neo4j.io
     NEO4J_USER=neo4j
     NEO4J_PASSWORD=your_password
     CHAT_MODEL=gpt-4o
  • —Build: pip install -r requirements.txt
  • —Start: python api.py

Option 2: Railway

bash
# Install Railway CLI
npm i -g @railway/cli

railway login
railway init
railway up

Add environment variables in Railway dashboard.

Option 3: Hugging Face (UI only)

  1. 1.Push to GitHub
  2. 2.Go to https://huggingface.co/spaces
  3. 3.Create Space → Streamlit
  4. 4.Point to your API URL (or deploy API separately)

Environment Variables

OPENAI_API_KEY=sk-...        # Required for LLM
QDRANT_URL=...             # Qdrant Cloud URL
NEO4J_URI=...              # Neo4j Aura bolt URL
NEO4J_USER=neo4j
NEO4J_PASSWORD=...
CHAT_MODEL=gpt-4o         # Default: gpt-4o

API Endpoints

EndpointDescription
POST /querySingle query (no memory)
POST /chatMulti-turn chat with memory
GET /chat/clearClear history
POST /ingestIndex documents
GET /healthHealth check

Project Structure

chat_architect/
├── api.py              # FastAPI application
├── ui.py              # Streamlit UI
├── Dockerfile         # API container
├── Dockerfile.ui      # UI container
├── docker-compose.yml
├── render.yaml       # Render config
├── scripts/
│   ├── ingest.py
│   ├── retrieval_pipeline.py
│   └── chat_agent.py
└── requirements.txt

License

MIT License