Team Ai
Apppublic

DoctorN8/ABK_Learning_Solutions

sourceHugging Facemitupdated 11mo agoView on Hugging Face
0likes
App README

๐Ÿ’ฌ 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

bash
pip install -r requirements.txt

2. Configure API Key

bash
# Copy the example environment file
copy .env.example .env

# Edit .env and add your Groq API key
# Get free key at: https://console.groq.com

Edit .env:

GROQ_API_KEY=your_actual_api_key_here
LLM_PROVIDER=groq
LLM_MODEL=llama-3.3-70b-versatile

3. Add Your Content

Place your markdown files in data/markdown_files/ directory. The system will automatically:

  • โ€”Load all .md files
  • โ€”Create embeddings
  • โ€”Build the search index

4. Launch the Chatbot

bash
python start_web.py

Open 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

  1. 1.Data Loading: Markdown files are loaded from data/markdown_files/
  2. 2.Embedding Creation: Text is chunked and converted to embeddings using sentence-transformers
  3. 3.Vector Search: User queries are matched against embeddings using FAISS
  4. 4.LLM Synthesis: Groq/Ollama generates coherent answers from retrieved context
  5. 5.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:

python
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

  1. 1.Create account at https://huggingface.co
  2. 2.Create new Space (Gradio)
  3. 3.Upload project files
  4. 4.Add GROQ_API_KEY to Space secrets

Docker

bash
docker build -t website-chatbot .
docker run -p 7860:7860 --env-file .env website-chatbot

Cloud Platforms

  • โ€”Render: Deploy as web service
  • โ€”Railway: One-click deploy
  • โ€”AWS/GCP/Azure: Deploy as container

๐Ÿ› ๏ธ Development

Test Individual Components

bash
# 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 .env file 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:

  1. 1.Check the markdown files are properly formatted
  2. 2.Verify API key is set correctly in .env
  3. 3.Ensure all dependencies are installed
  4. 4.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.