My girlfriend woke up today with the idea of being able to search for recipes based on ingredients from her food Pinterest board. Four hours later, she got this bot that does just that.
-
Pinterest Recipe Integration
- Fetch recipes directly from Pinterest boards.
- Scrape titles, images, and ingredients from recipe sites.
- Assigns cusine, difficulty, and time to each recipe.
- Store recipes in a structured JSON format.
-
Intelligent Ingredient Parsing
- Use local LLMs to interpret natural language ingredient queries (e.g.,
"What can I make with shrimp and garlic?"
). - Includes fuzzy search logic to match similar or related ingredients, ensuring flexibility (e.g.,
"red pepper flakes"
matches"pepper flakes"
or"ground pepper"
).
- Use local LLMs to interpret natural language ingredient queries (e.g.,
-
Discord Bot Commands
!recipe <query>
: Find recipes matching your ingredients.- Auto-DM rules to new users.
!gpt <query>
: For some general chat with the local LLM.!food <query>
: Smart search recipes using natural language, including filters like type, ingredients, difficulty, and time.
-
Python 3.8+
-
Install dependencies:
pip install -r requirements.txt
-
ChromeDriver installed (compatible with your Chrome version).
-
Set up
.env
:DISCORD_BOT_TOKEN=your_discord_token PINTEREST_EMAIL=your_email PINTEREST_PASSWORD=your_password
Fetch recipes from Pinterest boards and scrape recipe details:
python data/pinterest_scraper.py \
--board_url https://www.pinterest.com/<your_board> \
--driver_path /path/to/chromedriver \
--scroll_count 100 \
--workers 5 \
--output_file recipes.json
Output: recipes.json
with structured recipe data.
Assign features like cuisine, difficulty, etc, to the recipes:
python data/assign_cuisine.py \
--input_file recipes.json \
--output_file recipes.json
Output: recipes.json
with this new data added to each recipe.
Dataset: Made available on HuggingFace - https://huggingface.co/datasets/shanto268/pinterest_recipes
Launch the bot to interact on Discord:
python bot.py
Ask for recipes based on ingredients. Example:
!recipe I have 1 lb shrimp, red pepper flakes, and maybe some low-sodium chicken broth. Any recipe match?
Search recipes intelligently using natural language.
Examples:
-
By type of food:
!food show me 3 recipes for Italian food
-
Quick and easy recipes:
!food any easy seafood recipes that I can make for dinner?
-
By ingredients and a condition:
This project is open-source and available under the MIT License.
- Allow for exploratory chat features using the recipes.json knowledge base. e.g. "I want to make pasta" -> "What type of pasta?" -> "Spaghetti" -> "What sauce?" -> "Tomato" -> "Here's a recipe for Spaghetti with Tomato Sauce."