A Retrieval-Augmented Generation (RAG) based chatbot that combines the power of GPT-4 with custom knowledge retrieval capabilities. The chatbot can process and answer questions based on provided URLs and generate quizzes from the content.
- RAG Implementation: Combines vector embeddings with GPT-4 for context-aware responses
 - Custom Knowledge Base: Build vector store from provided URLs
 - Quiz Generation: Generate quizzes in Russian from the knowledge base
 - Smart Text Chunking: Intelligent text segmentation for optimal context retrieval
 - Vector Caching: Local caching of vector embeddings for improved performance
 
- Python 3.8+
 - OpenAI API key
 - Required Python packages (see Installation)
 
- Clone the repository:
 
git clone https://github.com/yourusername/RAG-ChatBot.git
cd RAG-ChatBot- Install required packages:
 
pip install -r requirements.txt- Set up your environment variables:
Create a 
.envfile in the root directory with: 
OPENAI_API_KEY=your_api_key_here
EMBEDDING_MODEL=text-embedding-ada-002  # or your preferred model
from src.chatbot.service import ChatBotService
# Initialize the chatbot with your URLs
urls = ["https://example.com/page1", "https://example.com/page2"]
chatbot = ChatBotService(urls)
# Get a response
response = chatbot.get_response("What is the main topic?")
print(response)
# Generate a quiz
quiz = chatbot.generate_test("specific topic")
print(quiz)The chatbot can generate quizzes in Russian from the provided content:
# Generate a quiz on a specific topic
quiz = chatbot.generate_test("artificial intelligence")
# Generate a random quiz
quiz = chatbot.generate_test()- 
Text Processing:
- URLs are scraped for content
 - Text is chunked into manageable pieces
 - Chunks are converted to vector embeddings
 
 - 
Query Processing:
- User query is converted to vector embedding
 - Similar chunks are retrieved using cosine similarity
 - Retrieved context is sent to GPT-4 for response generation
 
 - 
Quiz Generation:
- Content is retrieved based on topic
 - GPT-4 generates structured quiz questions
 - Questions are formatted and presented to the user
 
 
Run the test suite:
python -m unittest tests/test_chatbot.py- Fork the repository
 - Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
 
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for providing the GPT-4 and embedding APIs
 - Contributors and maintainers of the project