3.3 KiB
FAQ Bot – ChromaDB + Ollama
This project implements a simple FAQ bot that answers user queries using a vector store backed by ChromaDB and embeddings generated by Ollama. The bot is orchestrated with LangChain and includes a small tool that returns the current system time.
Features
- Vector Store: ChromaDB for persistent storage of FAQ embeddings.
- Embeddings: Generated with Ollama (e.g.,
llama3). - LLM: Ollama LLM for generating responses.
- RetrievalQA: LangChain chain that retrieves relevant FAQ answers.
- MCP‑Tool: A single tool that returns the current time when the user asks about time or date.
- CLI: Simple command‑line interface to ask questions or ingest data.
- Web API: FastAPI endpoint (
POST /ask) for programmatic access.
Prerequisites
- Python 3.10+
- Docker (optional, for running Ollama locally)
- Ollama server running locally (default port 11434)
Installation
# 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 use `.venv\Scripts\activate`
# Install dependencies
pip install -r requirements.txt
Environment Variables
Create a .env file in the project root (a template is provided):
OLLAMA_MODEL=llama3
CHROMA_DB_PATH=./chromadb
OLLAMA_MODEL: Name of the Ollama model to use (e.g.,llama3).CHROMA_DB_PATH: Directory where ChromaDB will store its data.
FAQ Data
Place your FAQ data in data/faq.csv. The file must contain two columns:
| question | answer |
|---|
A sample file is included in the repository.
Usage
CLI
# Ingest FAQ data (if not already ingested)
python -m src.main ask "What is the return policy?" --init
# Ask a question
python -m src.main ask "How do I track my order?"
The --init flag forces re‑ingestion of the FAQ data. If the vector store is empty, it will be ingested automatically.
Web API
# Start the server
python -m src.main serve
# Send a request
curl -X POST http://localhost:8000/ask \
-H "Content-Type: application/json" \
-d '{"question":"What payment methods are accepted?"}'
The response will be a JSON object:
{
"answer": "We accept credit cards, debit cards, and PayPal."
}
Adding New FAQ Entries
- Append new rows to
data/faq.csv. - Re‑index the vector store:
python -m src.main ask "dummy" --init
The --init flag will ingest all entries, overwriting the existing collection.
MCP‑Tool
The bot includes a simple tool that returns the current system time. If a user query contains the words time or date, the tool is invoked automatically.
Example:
python -m src.main ask "What time is it?"
Output:
Answer: 2026-08-01 14:32:07
Development
- Testing: Run the CLI or API locally to verify functionality.
- Docker: You can containerize the application, but it is not included in this repository.
Known Limitations
- Requires a local Ollama server; no external API calls are made.
- ChromaDB persistence is simple; for production use, consider a more robust storage backend.
- The MCP‑tool is minimal; replace or extend it as needed.
License
MIT License
Happy coding!