β οΈ Confidential Client Project (Rewritten Version)
This repository is a rewrite and refactor of a confidential client chatbot project.
All proprietary data, documents, and integrations have been removed or replaced with mock examples.
The codebase now serves as a clean, educational demonstration of AI-assisted retrieval and conversation using Python.
This project is a lightweight AI chatbot built with Flask and LangChain, designed to demonstrate a simple yet realistic retrieval-augmented generation (RAG) workflow.
It runs entirely locally (offline mock mode) or connects to OpenAIβs API if a valid key is provided.
A clean HTML + JS frontend allows real-time chat interaction through a browser.
-
π§ LangChain-based RAG pipeline
Retrieves and synthesizes document-based context dynamically. -
βοΈ Dual operation modes
- Online: Uses OpenAI Embeddings and GPT-based chat models
- Offline (mock mode): Uses
FakeEmbeddingsfor safe, API-free demo operation
-
π¬ Interactive frontend
Simple and responsive HTML/JavaScript chat interface built without frameworks. -
π Document retrieval
Loads and indexes text or PDF documents (via Chroma + LangChain loaders). -
π Confidential rewrite
All client content and data replaced with generic, safe mock examples.
aichatbot/ ββ app.py # Flask backend (retrieval logic + API routes) ββ requirements.txt # Dependency list ββ templates/ β ββ index.html # Frontend chat interface ββ static/ ββ style.css # Chat UI styling
git clone https://github.com/LiuyiLi2000/Ai-Python-Chatbot.git
cd Ai-Python-Chatbot
2οΈβ£ Create and activate a virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS/Linux
3οΈβ£ Install dependencies
pip install -r requirements.txt
4οΈβ£ (Optional) Add your OpenAI API key
setx OPENAI_API_KEY "sk-your-api-key"
# Restart terminal after setting
Without an API key, the chatbot runs in mock mode, generating simulated answers using local embeddings.
5οΈβ£ Run the Flask app
python app.py
Then open your browser at π http://127.0.0.1:5000
π» Example Questions
βWhere can I get free legal help in British Columbia?β
βWhat is Legal Aid BC?β
βShow me organizations offering community support.β
βοΈ Tech Stack
Layer Technologies
Backend Flask, Python
AI / RAG LangChain, Chroma
LLM OpenAI GPT (or FakeEmbeddings offline mode)
Frontend HTML, CSS, JavaScript
Data Handling PyPDFLoader, CharacterTextSplitter
π§© Modes of Operation
Mode Description
Live Mode Uses OpenAI API for embeddings & chat completions
Mock Mode Works completely offline using FakeEmbeddings and simulated responses
π§ Future Improvements
Add user-uploaded PDF ingestion
Support persistent chat sessions
Extend frontend with React or Streamlit
Integrate authentication for production use