DiabetesDietBot is an AI-powered chatbot developed by Syed Faizan for Mysore Medical College and Research Institute as part of a research study on how chatbots can assist doctors and medical students in recommending predefined diet plans to patients with Type 2 Diabetes.
The bot leverages Retrieval-Augmented Generation (RAG), FAISS vector search, and OpenAI’s GPT-3.5-turbo to provide personalized diet recommendations based on patient profiles, such as:
It uses a dataset of structured South Indian meal plans extracted from a PDF database to generate optimized diet recommendations.
📦 DiabetesDietBot
├── 📜 app.py # Main Gradio-based chatbot UI
├── 📜 rag.py # Retrieval-Augmented Generation (RAG) implementation
├── 📜 rag2.py # Alternative FAISS-based text processing
├── 📂 db_mealplans # FAISS vector store for meal plan retrieval
├── 📜 .env # Environment variables (OpenAI API key)
└── 📜 README.md # Project documentation (this file)
git clone https://github.com/your-repo/DiabetesDietBot.git
cd DiabetesDietBot
Ensure you have Python 3.8+ installed. Then run:
pip install -r requirements.txt
Create a .env
file in the project root and add your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key
The meal plans are extracted from MealPlans.pdf
using PyPDF2
:
from PyPDF2 import PdfReader
reader = PdfReader("MealPlans.pdf")
text = "\n".join([page.extract_text() for page in reader.pages])
The extracted text is embedded using OpenAIEmbeddings
and stored in a FAISS vector database:
from langchain_openai import OpenAIEmbeddings
from langchain_community.vectorstores import FAISS
embeddings = OpenAIEmbeddings()
vector_store = FAISS.from_texts([meal_plans_text], embedding=embeddings)
When a user inputs a query, FAISS retrieves top 3 most relevant meal plans:
docs = vector_store.similarity_search(user_input, k=3)
meal_suggestions = '\n\n'.join([doc.page_content for doc in docs])
A user-friendly Gradio-based chatbot interface allows interaction
The chatbot has a minimalist UI with meal plan visualization.
Users can input preferrences And receive a tailored meal plan optimized for Type 2 Diabetes.
The Diabetes Diet Bot was rigorously evaluated using RAGAS (Retrieval-Augmented Generation Assessment Score) metrics to assess the relevancy, correctness, and semantic similarity of the responses generated by the model.
Metric | Definition | Score (Avg.) |
---|---|---|
✅ Answer Relevancy | Measures how relevant the bot’s responses are to the user’s questions. | 0.9629 |
🎯 Answer Correctness | Evaluates the factual accuracy of the provided information. | 0.8276 |
🔗 Semantic Similarity | Assesses how semantically similar the bot’s answers are to the ground truth. | 0.9481 |
User Query | Answer Relevancy | Answer Correctness | Semantic Similarity |
---|---|---|---|
What is the meal plan for a Male in his 20s who is vegetarian with high caloric needs? | 0.9744 | 0.6247 | 0.8987 |
Suggest a meal plan for a Female in her 40s who is vegetarian with moderate caloric needs. | 0.9192 | 0.9050 | 0.9101 |
Provide a meal plan for a Male in his 60s with meat-based diet and moderate caloric needs. | 0.9711 | 0.8697 | 0.9790 |
Suitable meal plan for a Female in her 70s with meat-based meals and low caloric needs. | 0.9862 | 0.8698 | 0.9790 |
Meal plan for a Male in his 50s who is non-vegetarian with moderate caloric needs. | 0.9596 | 0.8690 | 0.9759 |
Query: “What is the meal plan for a Male in his 20s who is vegetarian with high caloric needs?”
Response:
Day 1:
The Diabetes Diet Bot demonstrates exceptional capability in generating personalized meal plans with high relevance, factual correctness, and semantic precision. Its performance makes it a reliable assistant for dietary consultations, particularly for diabetic and health-conscious individuals.
Note: Evaluation results were generated using RAGAS and logged with Weights & Biases (WandB) for comprehensive performance tracking.
This project is open-source and licensed under the MIT License.
🛠 Dr. Syed Faizan
📍 Mysore Medical College & Research Institute
🔗 LinkedIn
For collaborations or research inquiries, feel free to reach out!
© 2025 Syed Faizan. All Rights Reserved.