Files
povtornyy-ekzamen-faq-bot-c…/README.md
T

78 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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, filebased 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
1. **Clone the repository**
```bash
git clone <repo-url>
cd <repo-directory>
```
2. **Create a virtual environment** (optional but recommended)
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. **Install dependencies**
```bash
pip install -r requirements.txt
```
4. **Configure Ollama**
- Ensure Ollama is running locally (default port `11434`).
- Optionally set environment variables in a `.env` file:
```
OLLAMA_MODEL=llama3.1
OLLAMA_BASE_URL=http://localhost:11434
```
5. **Run the bot**
```bash
python src/main.py
```
Type your question in the console. Type `exit` or `quit` to stop.
## Project Structure
```
.
├── requirements.txt
├── src
│ └── main.py
└── README.md
```
- `requirements.txt` lists all Python dependencies, including `langchain-openai` and `qdrant-client` as 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 hardcoded in `src/main.py`. In a production setup, you would load this from a database or a file.
- The vector store persists in the `./chromadb` directory. Delete this folder to reindex from scratch.
- The bot uses the `stuff` chain 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.txt` again.
- **Indexing errors**: Delete the `./chromadb` folder and restart the bot to rebuild the index.
Enjoy your FAQ bot!