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
- Host: GitHub
- URL: https://github.com/ksm26/web-based-q-a-tool
- Owner: ksm26
- Created: 2025-03-20T11:47:45.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-20T12:16:57.000Z (over 1 year ago)
- Last Synced: 2025-03-20T12:48:32.482Z (over 1 year ago)
- Topics: ai, embeddings, faiss, fastapi, llama, llm, machine-learning, natural-language-processing, qa, qa-system, react-js, self-hosted-ai, tiny-llama, webscraping
- Language: Python
- Homepage: https://github.com/ksm26/Web-Based-Q-A-Tool
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```