feat: solution for 'Повторный экзамен: FAQ-бот — ChromaDB + один MCP-tool'

This commit is contained in:
2026-07-01 15:14:37 +03:00
parent 51ab1df383
commit b17c7be620
6 changed files with 334 additions and 110 deletions
+58 -32
View File
@@ -1,45 +1,71 @@
# FAQ Bot with ChromaDB
# FAQ Bot ChromaDB + MCP-tool
This project implements a simple FAQ bot that uses **ChromaDB** as the vector store and **MCP-tool** for generating embeddings. The bot indexes a set of FAQ entries and can answer user questions by retrieving the most relevant entries from the vector store.
This repository contains a lightweight FAQ bot that uses **ChromaDB** as the vector store and a single **MCP-tool** for generating embeddings.
The bot loads FAQ documents, stores them in ChromaDB, and answers user questions by retrieving the most relevant documents.
## Architecture
## Features
- **ChromaDB** the sole vector storage stack used for persisting embeddings and performing similarity queries.
- **MCP-tool** the only MCP-tool used for generating embeddings from text. No other vector store libraries or MCP-tools are included.
- **Single vector store stack** ChromaDB
- **One MCP-tool** for embeddings (OpenAI or deterministic fallback)
- Interactive commandline interface
- Easy to add new FAQ documents
## Setup
## Requirements
- Python 3.10+
- An OpenAI API key (optional a deterministic dummy embedding is used if not provided)
## Installation
```bash
# Install dependencies
npm install
# Run the bot
npm start
git clone https://git.brojs.ru/kuzakhmetovartur/povtornyy-ekzamen-faq-bot-chromadb-odin.git
cd povtornyy-ekzamen-faq-bot-chromadb-odin
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
```
## How It Works
## Configuration
1. **VectorStore**
- Connects to a local ChromaDB instance.
- Adds documents with embeddings generated by MCP-tool.
- Queries the collection for the topk most similar documents.
2. **Bot**
- Initializes the vector store.
- Indexes a predefined list of FAQs.
- Answers user questions by querying the vector store and returning the top results.
## Example
Running the bot will output:
Create a `.env` file in the project root with your OpenAI key:
```
Answer:
What is ChromaDB?
ChromaDB is a vector database designed for storing and querying embeddings efficiently.
---
How do I use MCP-tool?
MCP-tool is a utility that generates embeddings from text using a chosen model.
OPENAI_API_KEY=sk-...
```
Feel free to extend the FAQ list or integrate the bot into a larger application.
If the key is missing, the bot will use a deterministic dummy embedding.
## Usage
Place your FAQ documents as plain text files in the `data/` directory (one file per FAQ).
```bash
python src/faq_bot.py
```
You will see a prompt:
```
FAQ Bot is ready. Type your question (or 'exit' to quit).
Q:
```
Type a question and press Enter. The bot will display the top 3 most relevant answers.
## Project Structure
```
src/
├── faq_bot.py # Main entry point
├── vector_store.py # Wrapper around ChromaDB
└── mcp_tool.py # Embedding generation
```
## Extending
- **Adding new documents** drop new `.txt` files into `data/` and restart the bot.
- **Changing the embedding model** modify `mcp_tool.get_embedding` to use a different provider.
## License
MIT License