This repository contains a Recipe Chatbot that allows users to upload images of ingredients, detect the ingredients, and generate recipes using AI models like YOLO for image detection and Groq API for recipe generation.
LLVIS_FRUITS_AND_VEGETABLES
βββ backend
β βββ Recipe_Chatbot/ # Virtual environment folder
β βββ uploads/ # Folder to save uploaded images
β βββ runs/ # YOLO runs folder
β βββ main.py # FastAPI server
β βββ requirements.txt # Python dependencies
β βββ yolo_fruits_and_vegetables_v8x.pt # YOLO model weights
β βββ .env # Environment file (API keys)
β βββ Procfile # Deployment file (optional)
βββ frontend
β βββ node_modules/ # React dependencies
β βββ public/ # Static assets
β βββ src/ # React source code
β β βββ App.js # Main React component
β β βββ App.css # Styles
β β βββ index.js # Entry point for React
β β βββ chef-avatar.png # Chatbot avatar
β β βββ user-avatar.png # User avatar
β β βββ 2.png, 7.11.png # Additional assets
β βββ package.json # React dependencies
β βββ package-lock.json # Lockfile for dependencies
β βββ .env # Environment file (Backend URL)
βββ README.md # Documentation
- Image Upload: Detects ingredients in images using YOLO.
- Recipe Generation: Generates recipes based on detected ingredients using Groq API.
- Chatbot: Interactive chatbot to assist users with culinary questions.
cd backend
python -m venv Recipe_Chatbot
source Recipe_Chatbot/bin/activate # On Windows: backend\Recipe_Chatbot\Scripts\activate
pip install -r requirements.txt
Create a .env
file in the backend folder:
GROQ_API_KEY=your_groq_api_key_here
GROQ_MODEL=llama3-8b-8192
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
π Open http://127.0.0.1:8000/docs
to explore API documentation.
Groq API is used to generate recipes and chat responses.
Ensure you have a Groq API key from Groq.com.
Modify main.py
to load Groq API key from .env
:
import os
from dotenv import load_dotenv
import requests
# Load API key from .env file
load_dotenv()
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
GROQ_MODEL = os.getenv("GROQ_MODEL", "llama3-8b-8192")
GROQ_API_URL = "https://api.groq.com/openai/v1/chat/completions"
def query_groq(prompt):
headers = {
"Authorization": f"Bearer {GROQ_API_KEY}",
"Content-Type": "application/json",
}
payload = {
"model": GROQ_MODEL,
"messages": [{"role": "user", "content": prompt}],
"temperature": 0.7,
}
response = requests.post(GROQ_API_URL, json=payload, headers=headers)
return response.json()["choices"][0]["message"]["content"]
- Upload images via drag-and-drop or file upload.
- Displays detected ingredients and allows manual edits.
- Real-time chat with a recipe chatbot.
- Dynamic recipe generation with AI.
cd frontend
npm install
Create a .env
file in the frontend folder:
REACT_APP_BACKEND_URL=http://127.0.0.1:8000
npm start
π Open http://localhost:3000
to see your app.
- Method: POST
- Description: Uploads an image and detects ingredients using YOLO.
- Response:
{ "file_id": "unique-id", "ingredients": ["tomato", "onion"] }
- Method: POST
- Description: Generates a recipe based on detected ingredients.
- Method: POST
- Description: Responds to user queries in a culinary context.
β
Uses Groq API for AI-powered recipe generation
β
Uses .env
for secure API key management
β
Fully functional FastAPI backend & React frontend
π Your app is now ready for deployment! Let me know if you need any help! π₯π
Copyright (c) 2025, Alok Ahirrao
This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
You may use and modify this project for personal or educational purposes, but commercial use is prohibited without explicit permission.
For more details, see the LICENSE file or contact [email protected] .
Happy Cooking!