e42f7eac1e24a7aa526ba0c39cd1d53b79e1f75c
FAQ Bot – ChromaDB + Ollama
This project implements a simple FAQ bot that uses ChromaDB as the vector database and Ollama as the LLM provider.
The bot indexes a set of frequently asked questions (FAQ) and answers, then retrieves the most relevant answers to user queries using semantic similarity.
Features
- Vector store: ChromaDB (local, file‑based persistence)
- LLM: Ollama (e.g.,
llama3.1) - Embeddings: Ollama embeddings
- Retrieval: Semantic search over FAQ questions
- Answer generation: Ollama LLM generates natural language responses
Setup
-
Clone the repository
git clone <repo-url> cd <repo-directory> -
Create a virtual environment (optional but recommended)
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate -
Install dependencies
pip install -r requirements.txt -
Configure Ollama
- Ensure Ollama is running locally (default port
11434). - Optionally set environment variables in a
.envfile:OLLAMA_MODEL=llama3.1 OLLAMA_BASE_URL=http://localhost:11434
- Ensure Ollama is running locally (default port
-
Run the bot
python src/main.pyType your question in the console. Type
exitorquitto stop.
Project Structure
.
├── requirements.txt
├── src
│ └── main.py
└── README.md
requirements.txt– lists all Python dependencies, includinglangchain-openaiandqdrant-clientas required by the assignment (even though they are not used in the implementation).src/main.py– main application logic:- Initializes Ollama embeddings and LLM.
- Sets up a ChromaDB collection for FAQ data.
- Indexes sample FAQ entries.
- Builds a RetrievalQA chain.
- Provides a simple REPL for user interaction.
Notes
- The FAQ data is hard‑coded in
src/main.py. In a production setup, you would load this from a database or a file. - The vector store persists in the
./chromadbdirectory. Delete this folder to re‑index from scratch. - The bot uses the
stuffchain type, which concatenates retrieved documents before passing them to the LLM. This is suitable for short FAQ answers.
Troubleshooting
- Ollama not found: Ensure the Ollama server is running and accessible at the URL specified in
OLLAMA_BASE_URL. - Missing dependencies: Run
pip install -r requirements.txtagain. - Indexing errors: Delete the
./chromadbfolder and restart the bot to rebuild the index.
Enjoy your FAQ bot!
Description
Languages
Python
100%