An AI-powered chatbot designed to answer questions about political and philosophical subjects in Vietnamese education. It is built with a FastAPI backend and a vanilla JavaScript frontend.
- Real-time chat interface for seamless interaction.
- PDF file upload functionality with progress tracking.
- Visual feedback for various processing states.
- Responsive design ensuring compatibility across devices.
- Efficient PDF processing and knowledge extraction.
- BM25 ranking algorithm for determining context relevance.
- FAISS vector store for similarity-based searches.
- Integration with Google Gemini 1.5 Pro for advanced AI responses.
- Backend: FastAPI, LangChain, FAISS, Sentence Transformers
- Frontend: HTML5, CSS3, JavaScript
- AI: Google Generative AI (Gemini 1.5 Pro)
-
Install Python dependencies:
pip install -r requirements.txt
-
Start the FastAPI server:
uvicorn app:app --reload --port 8000
-
(Optional) Serve the frontend:
python -m http.server 8080
Alternatively, open
index.html
in a browser.
- Start the backend server.
- Open the frontend interface in your browser.
- (Optional) Upload PDF files to enrich the chatbot's knowledge base.
- Type questions into the chat input field.
- Receive detailed, AI-generated answers.
- Endpoint:
POST /upload
- Description: Accepts PDF files for processing and adds their content to the knowledge base.
- Response: Returns the processing status.
- Note: Includes a 30-second processing delay to ensure thorough extraction.
- Endpoint:
POST /answer
- Request Body:
{ "query": "Your question", "use_external_knowledge": true }
- Response: Provides the AI-generated answer along with the inference time.
- Chat Header: Displays the chatbot's title and logo for easy identification.
- Message History Display: Shows a chronological history of the conversation.
- File Upload Section: Enables users to upload PDFs with progress indicators for real-time updates.
- Question Input: Includes a text box and send button for submitting queries.
GOOGLE_API_KEY
: Your Google API key for integrating Gemini 1.5 Pro.
This chatbot was developed at the University of Information Technology - VNUHCM to enhance learning and engagement in political and philosophical education.