Rag-Chat-Bot is a Retrieval-Augmented Generation (RAG) chatbot that uses OpenAI's GPT-4 plus text-embedding-ada-002 to answer questions strictly from a custom chat dataset stored in a persistent ChromaDB collection.
- Loads chat data from a CSV file.
- Generates embeddings with OpenAI and stores them in a persistent ChromaDB collection on disk.
- Retrieves the top-k most relevant chats for each query via semantic search.
- Generates answers with GPT-4, constrained to the retrieved context.
-
Clone the repository and open it in VS Code (recommended — a Dev Container config is included).
-
Install dependencies:
pip install -r requirements.txt
-
Set your OpenAI API key by creating a
.envfile in the project root:OPENAI_API_KEY=your_openai_api_key -
Provide a chat CSV at
data/chat_training_2.csv. The script reads column index 1 as the chat id and column index 4 as the chat text. -
Run the chatbot:
python chatbot.py
When started, the chatbot will:
- Load the chats from
data/chat_training_2.csv. - Embed each chat and store it in a persistent ChromaDB collection (under
./chroma_db). - Prompt you for a query — type
exitor press Enter on an empty prompt to quit. - For each query, retrieve the 3 most similar chats and have GPT-4 answer using only that context.
chatbot.py— Main script (CLI loop, embedding, retrieval, generation).data/— Place your chat CSV here.requirements.txt— Python dependencies..devcontainer/— VS Code Dev Container configuration.