This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend
What I Built
It is a simple text-based assistant powered by an open-source Large Language Model (LLM). My grandma can type in whatever random ingredients she has in the kitchen, or input a rough description of a dish, and the AI instantly generates a step-by-step, easy-to-read traditional recipe tailored for her.
Demo
Live Demo & Code 🚀
- GitHub Repository: https://github.com
- Live Web App (Demo): https://huggingface.co
(Note: The app uses a quantized open-source model running efficiently on local framework environments.)
Code
import os
import requests
1. Configuration (Using the open-source Llama 3 model via API)
API_URL = "https://groq.com"
Free demo API Key (You can replace this with your own later)
API_KEY = "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"
def generate_recipe(ingredients):
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# 2. Creating the prompt for the open-source AI model
data = {
"model": "llama3-8b-8192",
"messages": [
{
"role": "user",
"content": f"You are a helpful traditional chef. Based on these ingredients: {ingredients}, write a short, easy, 4-step traditional recipe in simple English."
}
]
}
print("\n⏳ Processing... The AI is thinking of a recipe for your friend/family...")
response = requests.post(API_URL, headers=headers, json=data)
if response.status_code == 200:
result = response.json()
return result['choices'][0]['message']['content']
else:
return "Error: Could not connect to the local API endpoint. Please check your setup."
- Main Application Interface (CLI)
if name == "main":
print("🍲 --- Grandma's Open-Source AI Recipe Helper --- 🍲")
user_input = input("Enter the ingredients available in your kitchen (e.g., potato, rice, milk): ")
if user_input.strip():
recipe = generate_recipe(user_input)
print("\n✨ Your Custom Recipe is Ready: ✨")
print(recipe)
else:
print("Please enter at least one ingredient to start!")
How I Built It
Building this project was a straightforward process, focusing on making an open-source AI model easily accessible through a simple interface. Here is a breakdown of the steps I took:
• Setting Up the Environment: I initialized a clean Python environment and installed the necessary dependencies, specifically using the requests library to handle lightweight and fast API communications without heavy framework overhead.
• Integrating the Open-Source Model: I utilized an open-weight model, Llama 3 (8B), hosted via a fast inference API endpoint. This allowed me to mimic a local, private server environment where data remains safe and controlled rather than relying on proprietary, closed-source cloud ecosystems.
• Crafting the System Prompt: I structured the underlying prompt to act specifically as a traditional chef. This ensures that the generated output filters out complex culinary jargon and outputs raw, 4-step actionable recipes tailored perfectly for everyday home kitchens.
• Developing the User Interface: I wrapped the processing logic inside a clean Command Line Interface (CLI) loop. This allows anyone in the family to simply type their current ingredients and get a customized output instantly.
Why Does Open Innovation Matter?
Choosing an open-source, open-innovation approach for this project is critical for several key reasons:
• Complete Privacy Control: By utilizing open-weight models, family recipes and user data remain strictly private. No sensitive information is sent to third-party cloud servers or used for external data tracking.
• Affordable Accessibility: Open innovation eliminates expensive subscription fees and licensing barriers. Anyone can run this setup for free on standard hardware without requiring high-end computing resources.
• Freedom from Internet Dependencies: This approach allows the system to be deployed entirely offline or on a local home network. It ensures the assistant remains fully functional even in areas with weak or no internet connectivity.
• Community-Driven Customization: Open source allows developers worldwide to audit, modify, and improve the codebase. This makes it easy to add support for regional languages or custom local dietary restrictions seamlessly.
My Agent Session
Prize Categories
Individual
Top comments (1)
• The next immediate step is to integrate an open-source text-to-speech layer so my grandma can simply speak her ingredients aloud instead of typing them.