DoctorN8/ABK_Learning_Solutions
๐ฌ Website RAG Chatbot
A powerful AI-powered chatbot for your website that uses RAG (Retrieval-Augmented Generation) to answer questions about your services, projects, and content. Built with modern NLP techniques, FAISS vector search, and LLM integration.
โจ Features
- ๐ค LLM-Enhanced Responses: Uses Groq (fast) or Ollama (local) for intelligent answers
- ๐ RAG Architecture: Combines semantic search with LLM reasoning
- ๐ Web Interface: Beautiful Gradio UI for easy interaction
- ๐ Source Citations: All answers include specific source references
- โก Fast Semantic Search: FAISS-powered vector search
- ๐ง Multiple LLM Providers: Choose between Groq (API) or Ollama (local)
- ๐ Markdown-Based: Simply add your website content as markdown files
๐ Quick Start
1. Install Dependencies
pip install -r requirements.txt2. Configure API Key
# Copy the example environment file
copy .env.example .env
# Edit .env and add your Groq API key
# Get free key at: https://console.groq.comEdit .env:
GROQ_API_KEY=your_actual_api_key_here
LLM_PROVIDER=groq
LLM_MODEL=llama-3.3-70b-versatile3. Add Your Content
Place your markdown files in data/markdown_files/ directory. The system will automatically:
- Load all
.mdfiles - Create embeddings
- Build the search index
4. Launch the Chatbot
python start_web.pyOpen your browser to: http://localhost:7860
๐ Project Structure
Website RAG Chatbot/
โ
โโโ data/
โ โโโ markdown_files/ # Your website content (markdown files)
โ โโโ services.md
โ โโโ about.md
โ โโโ contact.md
โ โโโ ... (add your 19 files here)
โ
โโโ src/
โ โโโ data_loader.py # Loads markdown files
โ โโโ embedding_indexer.py # Creates FAISS index
โ โโโ llm_generator.py # LLM response generation
โ โโโ search.py # Unified search interface
โ โโโ main.py # Gradio web interface
โ
โโโ app.py # Entry point for deployment
โโโ start_web.py # Local startup script
โโโ requirements.txt # Python dependencies
โโโ .env.example # Environment variables template
โโโ README.md # This file๐ง How It Works
- Data Loading: Markdown files are loaded from
data/markdown_files/ - Embedding Creation: Text is chunked and converted to embeddings using sentence-transformers
- Vector Search: User queries are matched against embeddings using FAISS
- LLM Synthesis: Groq/Ollama generates coherent answers from retrieved context
- Source Attribution: Answers include references to source files
๐ฏ LLM Provider Options
Groq (Recommended) โก
- Speed: 300+ tokens/second
- Cost: Free tier available
- Quality: Llama 3.3 70B
- Setup: Get API key from https://console.groq.com
Ollama (Local Alternative) ๐
- Speed: 20-30 tokens/second
- Cost: 100% free
- Quality: Llama 3.2 8B
- Setup: Install Ollama locally
๐ Customization
Update Content
Simply add/edit markdown files in data/markdown_files/ and restart the application. The index will be rebuilt automatically.
Adjust Chunk Size
Edit src/data_loader.py:
def _create_chunks(self, chunk_size: int = 800, overlap: int = 150)Change System Prompt
Edit src/llm_generator.py in the _get_system_prompt() method to customize the chatbot's personality and behavior.
Customize UI
Edit src/main.py to modify the Gradio interface, colors, examples, and branding.
๐ Deployment Options
Hugging Face Spaces
- Create account at https://huggingface.co
- Create new Space (Gradio)
- Upload project files
- Add
GROQ_API_KEYto Space secrets
Docker
docker build -t website-chatbot .
docker run -p 7860:7860 --env-file .env website-chatbotCloud Platforms
- Render: Deploy as web service
- Railway: One-click deploy
- AWS/GCP/Azure: Deploy as container
๐ ๏ธ Development
Test Individual Components
# Test data loader
python src/data_loader.py
# Test embedding indexer
python src/embedding_indexer.py
# Test search engine
python src/search.py
# Test LLM generator
python src/llm_generator.py๐ Performance
- Index Creation: ~30 seconds for 19 markdown files
- Query Response: 1-3 seconds with Groq
- Memory Usage: ~500MB with loaded index
- Concurrent Users: Supports multiple simultaneous queries
๐ Security Notes
- Never commit
.envfile with real API keys - Use environment variables for sensitive data
- Consider rate limiting for production deployment
- Validate and sanitize user inputs
๐ License
MIT License - Feel free to use for commercial projects
๐ค Support
For issues or questions:
- Check the markdown files are properly formatted
- Verify API key is set correctly in
.env - Ensure all dependencies are installed
- Check logs for error messages
๐ Based On
This project is adapted from the Florida Masonic Law Assistant, demonstrating the flexibility of RAG systems for different content domains.
