Have you ever come home or shut the laptop and walked out of your home office and wondered: "What am I going to make for dinner"? Maybe you have kids pleading with you for something delicious. Maybe it's you at home by yourself and you know you don't want to order takeout again from your local unhealthy restaurant.
What do you do?
Well, worry no more! The What's for Dinner AI Assistant is here! Simply take a picture of the contents of your refrigerator, send it to the AI assistant, and let it generate numerous delicious meal options for you based on what you already have at home. Why waste your valuable time thinking and planning of what to make when you can let AI do it for you?
How does it work?
The What's for Dinner AI Assistant is a Ruby on Rails application that utilizes OpenAI's GPT-4o model to analyze the contents of the image uploaded and return a list of feasible and realistic meal options. Each meal title takes the user to an endless array of actual recipe instructions for that meal option.
Take a look at an example snippet of code from the assistant. In #fetch_recipes_from_openai
, the list of items in the refrigerator is sent to the GPT-4o model and the response is a comma delimited list of meal options:
def fetch_recipes_from_openai(items_in_fridge)
response = OPENAI.chat(
parameters: {
model: "gpt-4o",
messages: [
{ role: "system", content: "You are an assistant tasked with listing recipes that can be made with the following items in the fridge: #{items_in_fridge}."},
{ role: "system", content: "List the recipes in a comma-separated list and nothing else. Do not include any other information or any other text." },
]
}
)
response.dig("choices", 0, "message", "content").split(',').map(&:strip)
end
All of the meal options for that day are conveniently stored in Couchbase using Capella, Couchbase's database as a service. The flexible JSON document model of Couchbase allows the AI Assistant to easily adapt to any changing needs as it is not tied down to a rigid database schema.
Whether you want to deploy your AI Assistant to a provider like AWS or you want to run it locally, both options are possible. Locally, the AI Assistant leverages ngrok to create an externally accessible connection for OpenAI to access the uploaded image for analysis.
Further instructions along with the entire codebase are provided on GitHub.