This project is an AI-driven chatbot fine-tuned with the Gemini 1.5 Flash LLM model. It interacts with a dataset of fictional student information, answering questions about student profiles while handling both in-dataset and out-of-dataset queries. The chatbot is built with a FastAPI backend and a React frontend, ensuring seamless communication and efficient response handling. It also features chat history storage using MongoDB, with session persistence via local storage, and provides users with a dedicated history page for reviewing past interactions.
- AI-Driven Responses: Fine-tuned with student data using Gemini 1.5 Flash LLM to provide precise answers to queries.
- FastAPI Backend: Efficient API handling and scalable architecture for seamless server-client communication.
- React Frontend: Interactive user interface with real-time communication and response rendering.
- MongoDB Integration: Stores chat history dynamically, allowing real-time retrieval and review of previous conversations.
- Local Storage: Persists chat history across sessions for better user experience and continuity.
- Dedicated History Page: Displays a complete log of past conversations for easy reference.
- In-Dataset and Out-of-Dataset Handling: Accurately manages both known and unknown queries with appropriate responses.
- Backend: FastAPI, Python
- Frontend: React, JavaScript
- Database: MongoDB (for chat history)
- Model: Gemini 1.5 Flash LLM (fine-tuned with student data)
- Deployment: Google Cloud SDK, Google AI Studio
- Storage: Local Storage (for session persistence)
Ensure you have the following installed:
- Python 3.7+
- Node.js and npm (for React frontend)
- MongoDB (for storing chat history)
- Google Cloud SDK (for model fine-tuning and deployment)
- FFmpeg (for Flask backend audio handling)
- Gemini API Key and Model ID
-
Clone the repository:
git clone https://github.com/GauravOOO2/Fine_Tuned_Student_Data_AI_ChatBot_Backend.git cd Fine_Tuned_Student_Data_AI_ChatBot_Backend
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
Create a
.env
file in the backend folder and add your credentials:GEMINI_API_KEY=<your-gemini-api-key> MONGODB_URI=<your-mongodb-uri>
-
Run the FastAPI server:
uvicorn main:app --reload
-
Navigate to the frontend folder:
git clone https://github.com/GauravOOO2/Fine_Tuned_Student_Data_AI_ChatBot_FrontEnd.git
cd Fine_Tuned_Student_Data_AI_ChatBot_FrontEnd
-
Install dependencies:
npm install
-
Start the React development server:
npm start
- Ensure MongoDB is running locally or provide a connection URI. The chat history is stored dynamically in MongoDB.
- Set the MongoDB URI in the backend's
.env
file.
-
Fine-tune the Gemini 1.5 Flash LLM using Google Cloud SDK and AI Studio. The dataset used contains fictional student information in JSON format.
-
Model ID and API Key should be included in the
.env
file.
Once both the backend and frontend servers are running, you can access the chatbot by navigating to:
http://localhost:3000
- Chat with the Bot: Ask questions about students, and the chatbot will respond using the fine-tuned Gemini model.
- Chat History: Check the "History" tab to view past conversations.
- Session Persistence: The chatbot will remember past conversations using local storage.
- "What is the age of John Doe?"
- "Who is Jane Smith's oncologist?"
- "Which school does Alex attend?"
- "What is the percentage of Lily Thompson?"
For any out-of-dataset queries, the chatbot will gracefully handle them with appropriate fallback responses.
.
├── backend
│ ├── app
│ │ ├── main.py # FastAPI backend implementation
│ │ ├── database.py # MongoDB connection and schema
│ │ └── models.py # Defines schema for chat history
├── frontend
│ ├── public # Public files (index.html, etc.)
│ ├── src
│ │ ├── components # React components
│ │ ├── pages # Pages for chat and history
│ │ ├── App.js # Main React component
│ │ └── index.js # Entry point for React app
└── README.md
- Support for Multiple Datasets: Extend the chatbot’s ability to handle multiple datasets or domains.
- Enhanced Natural Language Understanding: Improve chatbot’s understanding and flexibility in answering more complex queries.
- User Authentication: Add user login and personalized chat history for individual users.
Contributions are welcome! Please fork the repository and create a pull request with your changes. Ensure that your code follows the existing code style and includes relevant tests.
If you have any questions or suggestions, feel free to reach out:
- Gaurav Varma – LinkedIn
- GitHub – YourGitHubProfile