An open API service indexing awesome lists of open source software.

https://github.com/ksm26/web-based-q-a-tool

Web-Based Q&A Tool enables users to extract and query website content using FastAPI, FAISS, and a local TinyLlama-1.1B modelβ€”without external APIs. Built with React, it offers a minimal UI for seamless AI-driven search
https://github.com/ksm26/web-based-q-a-tool

ai embeddings faiss fastapi llama llm machine-learning natural-language-processing qa qa-system react-js self-hosted-ai tiny-llama webscraping

Last synced: 3 months ago
JSON representation

Web-Based Q&A Tool enables users to extract and query website content using FastAPI, FAISS, and a local TinyLlama-1.1B modelβ€”without external APIs. Built with React, it offers a minimal UI for seamless AI-driven search

Awesome Lists containing this project

README

          

# 🌐 Web-Based Q&A Tool

A simple web application that allows users to:
βœ… **Ingest website content** by providing URLs.
βœ… **Ask questions** based strictly on the ingested content.
βœ… **Get concise, AI-generated answers** without using external knowledge.

---

## πŸš€ Features

- **Web Scraping**: Extracts text content from webpages.
- **Embeddings & Retrieval**: Uses FAISS for fast search.
- **Local LLM Support**: Runs AI-based Q&A without OpenAI API.
- **Minimal UI**: Built with React for easy interaction.

---

## πŸ“‚ Project Structure

web_based_QA/

│── backend/ # FastAPI backend
β”‚ β”œβ”€β”€ app.py # Main API
β”‚ β”œβ”€β”€ scraper.py # Web scraping logic
β”‚ β”œβ”€β”€ embeddings.py # FAISS index & text embeddings
β”‚ β”œβ”€β”€ model.py # Local LLM for Q&A
β”‚ β”œβ”€β”€ requirements.txt # Backend dependencies
│── frontend/ # React frontend
β”‚ β”œβ”€β”€ src/
β”‚ β”‚ β”œβ”€β”€ App.js # Main UI component
β”‚ β”‚ β”œβ”€β”€ api.js # Axios API calls
β”‚ β”‚ β”œβ”€β”€ index.css # Minimal UI styles
β”‚ β”œβ”€β”€ package.json # Frontend dependencies
│── README.md # Documentation

---

## πŸ› οΈ Tech Stack

| Component | Technology Used |
|------------|----------------|
| **Backend** | FastAPI, FAISS, Sentence Transformers, Llama.cpp |
| **Frontend** | React, Axios, JavaScript |
| **Scraping** | BeautifulSoup, Requests, Selenium (for JS-heavy pages) |
| **LLM** | TinyLlama-1.1B (GGUF format) |

---

## πŸš€ Setup Instructions

### **1️⃣ Clone the Repository**
```sh
git clone https://github.com/your-username/web_based_QA.git
cd web_based_QA
```

### **2️⃣ Install Dependencies**
```sh
cd backend
pip install -r requirements.txt
```

### **3️⃣ Download a Local LLM Model (TinyLlama)**
```sh
mkdir -p models
cd models
wget https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf
```

### **4️⃣ Start the Backend**
```sh
cd backend
uvicorn app:app --reload --host 0.0.0.0 --port 8000
```

## 🎨 Frontend Setup (React)

### **5️⃣ Install Dependencies**
```sh
cd frontend
npm install
```

### **6️⃣ Start the React App**
```sh
npm start
```

## 🌍 Usage
### **7️⃣ Ingest a Webpage**
```sh
curl -X POST "http://127.0.0.1:8000/ingest" \
-H "Content-Type: application/json" \
-d '{"url": "https://www.un.org/en/observances/international-nowruz-day"}'
```
πŸ“Œ Expected Response:
```sh
{"message": "Content ingested successfully!"}
```

### **8️⃣ Ask a Question**
```sh
curl -X POST "http://127.0.0.1:8000/ask" \
-H "Content-Type: application/json" \
-d '{"question": "What is International Nowruz Day?"}'

```
πŸ“Œ Expected Response:
```sh
{"answer": "International Nowruz Day celebrates the Persian New Year, observed on March 21st..."}

```

## πŸš€ Deployment

### Backend Deployment
```sh
gunicorn -w 4 -k uvicorn.workers.UvicornWorker app:app
```

### Frontend Production Build
```sh
cd frontend
npm run build

```