85 lines
2.1 KiB
Markdown
85 lines
2.1 KiB
Markdown
# FAQ Bot – ChromaDB + MCP-tool
|
||
|
||
This repository contains a simple FAQ bot that uses **ChromaDB** for vector storage and a single **MCP-tool** for auxiliary functionality. The bot answers user questions by retrieving relevant FAQ documents and generating responses with OpenAI’s LLM.
|
||
|
||
## Features
|
||
|
||
- **Vector search** with ChromaDB (persisted locally).
|
||
- **OpenAI embeddings** (`text-embedding-ada-002`) for document indexing.
|
||
- **OpenAI function calling** to invoke a single MCP-tool (`get_current_utc_time`).
|
||
- Interactive command‑line interface.
|
||
|
||
## Setup
|
||
|
||
1. **Clone the repository**
|
||
|
||
```bash
|
||
git clone https://git.brojs.ru/kuzakhmetovartur/povtornyy-ekzamen-faq-bot-chromadb-odin.git
|
||
cd povtornyy-ekzamen-faq-bot-chromadb-odin
|
||
```
|
||
|
||
2. **Create a virtual environment**
|
||
|
||
```bash
|
||
python -m venv .venv
|
||
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
||
```
|
||
|
||
3. **Install dependencies**
|
||
|
||
```bash
|
||
pip install -r requirements.txt
|
||
```
|
||
|
||
4. **Set environment variables**
|
||
|
||
Create a `.env` file in the project root:
|
||
|
||
```dotenv
|
||
OPENAI_API_KEY=your_openai_api_key
|
||
FAQ_FILE=data/faq.jsonl # optional, defaults to data/faq.jsonl
|
||
```
|
||
|
||
5. **Prepare FAQ data**
|
||
|
||
Place your FAQ documents in `data/faq.jsonl`. Each line should be a JSON object:
|
||
|
||
```json
|
||
{"id": "1", "text": "What is ChromaDB?", "metadata": {"category": "database"}}
|
||
{"id": "2", "text": "How to use the MCP-tool?", "metadata": {"category": "tool"}}
|
||
```
|
||
|
||
If the file is missing, the bot will start without pre‑loaded documents.
|
||
|
||
## Running the Bot
|
||
|
||
```bash
|
||
python src/main.py
|
||
```
|
||
|
||
You will see:
|
||
|
||
```
|
||
FAQ Bot (ChromaDB + MCP-tool). Type 'exit' to quit.
|
||
You:
|
||
```
|
||
|
||
Type a question, e.g.:
|
||
|
||
```
|
||
You: What is the current time?
|
||
```
|
||
|
||
The bot may invoke the MCP-tool and return the current UTC time.
|
||
|
||
## Testing
|
||
|
||
The repository includes no automated tests, but you can manually verify:
|
||
|
||
- The bot can answer FAQ questions.
|
||
- The MCP-tool is invoked when the model requests it.
|
||
- ChromaDB persists data between runs (check the `chromadb/` directory).
|
||
|
||
## License
|
||
|
||
MIT License |