2.3 KiB
2.3 KiB
FAQ Bot – ChromaDB + Ollama Embeddings
This project implements a simple FAQ chatbot that uses ChromaDB as the vector store and Ollama for embeddings. The chatbot answers user questions by retrieving the most relevant FAQ entries and generating a response with an OpenAI LLM.
Features
- Vector Store: ChromaDB (persistent on disk)
- Embeddings: Ollama
all-MiniLM-L6-v2(or any other Ollama model) - LLM: OpenAI GPT-3.5-turbo (configurable)
- API: FastAPI with
/askand/addendpoints
Setup
-
Clone the repository
git clone https://git.brojs.ru/kuzakhmetovartur/povtornyy-ekzamen-faq-bot-chromadb-odin.git cd povtornyy-ekzamen-faq-bot-chromadb-odin -
Create a virtual environment
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate -
Install dependencies
pip install -r requirements.txt -
Set environment variables
Create a
.envfile in the project root (or export variables manually):# ChromaDB CHROMA_DB_PATH=./chroma_db CHROMA_COLLECTION_NAME=faq_collection # Ollama OLLAMA_EMBED_MODEL=all-MiniLM-L6-v2 OLLAMA_HOST=http://localhost OLLAMA_PORT=11434 # OpenAI OPENAI_API_KEY=your_openai_api_key OPENAI_MODEL=gpt-3.5-turbo -
Run the server
uvicorn src.main:app --reloadThe API will be available at
http://127.0.0.1:8000.
API Endpoints
| Method | Path | Description |
|---|---|---|
POST |
/ask |
Ask a question. Body: { "question": "Your question" }. Response: { "answer": "..." }. |
POST |
/add |
Add a new FAQ entry. Body: { "text": "...", "metadata": { ... } }. Response: { "status": "added" }. |
Adding FAQ Data
You can add FAQ entries via the /add endpoint or by modifying the code to load a dataset on startup. Each entry is stored as a Document in ChromaDB with optional metadata.
Notes
- The vector store is persisted in the directory specified by
CHROMA_DB_PATH. Deleting this directory will remove all stored vectors. - Ollama must be running locally and expose the embedding endpoint on the host/port specified.
- The OpenAI LLM requires a valid API key.