A React-based AI-powered QA chatbot that generates structured test cases from PDF documents using AI21βs Jamba model.
This application enables you to upload PDFs, extract text content, and generate test cases interactively via a modern chat interface.
- π PDF Upload & Text Extraction β Upload PDF files and extract readable text
- π€ AI-Powered Test Case Generation β Generate detailed test cases using AI21βs Jamba Large model
- β‘ Real-time Streaming β Character-by-character streaming for a natural conversation feel
- π Dark/Light Theme β Switch between dark and light modes for better UX
- πΎ Chat History β Persistent conversation storage with SQLite
- π± Responsive Design β Works smoothly across desktop and mobile devices
- π One-click Copy β Copy generated test cases to clipboard easily

- React 18 (with Hooks)
- ReactMarkdown + remark-gfm (render markdown responses)
- CSS-in-JS (dynamic theming with light/dark support)
- Flask (Python web framework)
- AI21 SDK (Jamba model integration)
- SQLAlchemy (SQLite ORM)
- PyMuPDF & pdfplumber (PDF text extraction)
- Flask-CORS (CORS support)
- Node.js (v16 or higher)
- Python (3.8+)
- AI21 API key (Get one here)
git clone https://github.com/your-username/ai-qa-chatbot.git
cd ai-qa-chatbot
cd frontend
npm install
npm install react-markdown remark-gfm
cd backend
# Create & activate virtual environment
python -m venv venv
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
# Install dependencies
pip install flask flask-cors sqlalchemy pymupdf pdfplumber ai21 werkzeug
In backend/app.py
, replace with your API key:
AI21_API_KEY = "your-ai21-api-key-here"
In frontend/src/App.js
(or config file):
const API_BASE = 'http://localhost:5000';
cd backend
python app.py
Server runs at: http://localhost:5000
cd frontend
npm start
Frontend runs at: http://localhost:3000
- Upload PDF β Select a PDF file
- Review Extracted Text β Verify extracted content
- Generate Test Cases β Ask chatbot to generate test cases
- Copy Results β Use "Copy Test Cases" button
- Switch Theme β Toggle between light/dark mode
Method | Endpoint | Description |
---|---|---|
POST | /upload_pdf |
Upload & extract text from PDF files |
POST | /chat_stream |
Generate streaming AI responses |
GET | /history |
Retrieve chat history |
ai-qa-chatbot/
βββ frontend/
β βββ src/
β β βββ App.js # Main React component
β β βββ index.js # Entry point
β βββ public/
β βββ package.json
βββ backend/
β βββ app.py # Flask backend
β βββ uploads/ # PDF upload directory
β βββ chat_history.db # SQLite database
βββ README.md
- Multiple extraction methods (PyMuPDF, pdfplumber)
- Handles various PDF layouts and formats
- Validates minimum text length
- Uses AI21 Jamba-large model
- Context truncation for large docs
- Structured prompting for consistent test case format
- Typing animation (adjustable speed)
- Responsive breakpoints (default: 980px)
- Persistent theme preference
MAX_CONTEXT_CHARS
= 8000 (default)MIN_TEXT_LEN
= 200 (default)PRIMARY_MODEL
="jamba-large"
- PDF Upload β Max size 64MB, validates text extraction quality
- AI Responses β Graceful handling of API errors
- Network β Timeout handling & retries
- File Processing β Fallback extraction methods
-
Fork this repo
-
Create a new branch:
git checkout -b feature/your-feature
-
Commit changes:
git commit -am "Add new feature"
-
Push branch:
git push origin feature/your-feature
-
Open a Pull Request
- AI21 Labs for the Jamba model
- React Community for docs and ecosystem
- Flask for the backend framework