RAG-DietAssistant / README.md
Beable's picture
Upload 6 files
a144435 verified
---
title: AI Diet Planner & Nutrition Assistant
emoji: 🍽️
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 4.44.0
app_file: app.py
pinned: false
license: mit
short_description: AI-powered diet planning with nutrition analysis
---
# 🍽️ AI Diet Planner & Nutrition Assistant
An intelligent diet planning application that uses RAG (Retrieval-Augmented Generation) technology to provide personalized nutrition advice, meal planning, and dietary recommendations.
## ✨ Features
### 🎯 **Personalized Diet Planning**
- **Weekly Meal Plans**: Complete 7-day diet plans with detailed meal breakdowns
- **Daily Nutrition**: Individual day meal planning with macro and micronutrient analysis
- **Customizable Parameters**: Age, weight, height, activity level, and dietary preferences
### πŸ“Š **Nutrition Analysis**
- **Comprehensive Nutrition Facts**: Detailed breakdown of calories, macronutrients, vitamins, and minerals
- **USDA Food Database**: Access to extensive food nutrition information
- **BMR & TDEE Calculations**: Accurate metabolic rate calculations using Mifflin-St Jeor formula
### πŸ€– **AI-Powered Recommendations**
- **Smart Suggestions**: Personalized dietary recommendations based on your profile
- **Goal-Oriented Planning**: Weight loss, muscle gain, or maintenance-focused plans
- **Interactive Chat**: Natural language interface for easy interaction
### πŸ“‹ **Advanced Features**
- **JSON Export**: All plans and analyses saved as structured JSON files
- **Table Formatting**: Beautiful markdown tables for easy reading
- **Multi-language Support**: English interface with comprehensive food database
## πŸš€ How to Use
### 1. **Create a Diet Plan**
```
"Create a weekly diet plan for a 25-year-old male, 70kg, 175cm, moderate activity"
```
### 2. **Calculate Nutrition**
```
"Calculate nutrition for 200g chicken breast and 150g rice"
```
### 3. **Get Recommendations**
```
"Get diet recommendations for weight loss"
```
### 4. **Vegetarian Options**
```
"Create a vegetarian meal plan for 7 days"
```
## πŸ”§ Technical Details
### **Architecture**
- **RAG System**: Retrieval-Augmented Generation for intelligent responses
- **Groq API**: Fast LLM inference for real-time responses
- **Sentence Transformers**: Semantic search for relevant nutrition data
- **Gradio**: Modern web interface for easy interaction
### **Data Sources**
- **USDA FoodData Central**: Comprehensive nutrition database
- **Custom Food Database**: Curated collection of common foods
- **Nutritional Algorithms**: BMR, TDEE, and macro distribution calculations
### **Output Formats**
- **JSON Files**: Structured data for all plans and analyses
- **Markdown Tables**: Human-readable formatted output
- **Interactive Chat**: Real-time conversation interface
## πŸ“ File Structure
```
β”œβ”€β”€ app.py # Main Gradio application
β”œβ”€β”€ main3.py # RAG system and tool router
β”œβ”€β”€ diet_tool.py # Diet planning algorithms
β”œβ”€β”€ usda_provider.py # USDA API integration
β”œβ”€β”€ requirements.txt # Python dependencies
β”œβ”€β”€ README.md # This file
└── outputs/ # Generated JSON files
β”œβ”€β”€ diet_plan_weekly_*.json
β”œβ”€β”€ diet_plan_daily_*.json
└── diet_recommendations_*.json
```
## πŸ› οΈ Setup Instructions
### **For Hugging Face Spaces**
1. **Create a new Space** on Hugging Face
2. **Upload all files** to your Space repository
3. **Set Environment Variables**:
- Go to Settings β†’ Secrets
- Add `GROQ_API_KEY` with your Groq API key
4. **Deploy** - The Space will automatically build and deploy
### **For Local Development**
1. **Install Dependencies**:
```bash
pip install -r requirements.txt
```
2. **Set Environment Variable**:
```bash
export GROQ_API_KEY="your_groq_api_key_here"
```
3. **Run the Application**:
```bash
python app.py
```
## πŸ”‘ API Keys Required
- **Groq API Key**: Get your free API key from [console.groq.com](https://console.groq.com)
## πŸ“Š Example Outputs
### **Weekly Diet Plan**
- 7-day meal breakdown
- Daily calorie and macro targets
- Detailed food lists with portions
- Nutritional analysis per meal
### **Nutrition Analysis**
- Complete macronutrient breakdown
- Vitamin and mineral content
- Calorie calculations
- Serving size recommendations
### **Dietary Recommendations**
- Personalized advice based on profile
- Goal-specific suggestions
- Macro distribution guidance
- Lifestyle integration tips
## 🀝 Contributing
Feel free to contribute to this project by:
- Adding new food items to the database
- Improving nutrition calculation algorithms
- Enhancing the user interface
- Adding new dietary patterns (keto, paleo, etc.)
## πŸ“„ License
This project is licensed under the MIT License - see the LICENSE file for details.
## πŸ™ Acknowledgments
- **USDA FoodData Central** for comprehensive nutrition data
- **Groq** for fast LLM inference
- **Gradio** for the beautiful web interface
- **Sentence Transformers** for semantic search capabilities
---
**Made with ❀️ for better nutrition and healthier living!**