-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.py
74 lines (59 loc) Β· 2.31 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import streamlit as st
from openai_api import extract_food_from_image, chatgpt
def main():
st.title("Refrigerator Chef π§βπ³π½οΈ")
st.markdown("## Let's find the perfect meal for you today! π")
st.markdown("Tell us about your preferences and what's in your fridge.")
with st.expander("Set Your Food Preferences"):
cuisine = st.selectbox(
"Cuisine Preference:",
["Italian", "Mexican", "Asian", "Other"],
index=0,
)
diet = st.selectbox(
"Dietary Restrictions:",
["None", "Vegetarian", "Vegan", "Gluten-Free", "Low-Carb"],
index=0,
)
flavor = st.selectbox(
"Flavor Profile:",
["Spicy", "Sweet", "Savory", "Mix"],
index=2,
)
meal_type = st.selectbox(
"Meal Type:",
["Light (Salad, Sandwich)", "Hearty (Pasta, Steak)"],
index=1,
)
preferences = (
f"Cuisine Preference: {cuisine}\n"
f"Dietary Restrictions: {diet}\n"
f"Flavor Profile: {flavor}\n"
f"Meal Type: {meal_type}"
)
st.markdown("## Now, show us what's in your fridge! πΈ")
image_link = st.text_input(
"Enter the link to an image of the contents of your fridge:",
"https://healsview.com/wp-content/uploads/2023/10/open-fridge-or-1024x683.jpg",
)
if st.button("Find Recipe"):
ingredients = extract_food_from_image(image_link)
col1, col2 = st.columns(2)
with col1:
st.image(image_link, caption="Image from URL", use_column_width=True)
with col2:
st.markdown(f"**Ingredients in your fridge:**\n{ingredients}")
main_prompt = """
Given my food preferences and ingredients I have in my fridge, what should I cook for dinner tonight? DO NOT use any additional ingredients. Make me a full recipe. Write your response in markdown.
My food preferences:
{preferences}
Ingredients I have in my fridge:
{ingredients}
""".format(
preferences=preferences, ingredients=ingredients
)
response = chatgpt(main_prompt.strip())
st.markdown("## Your Custom Recipe π")
st.markdown(response)
if __name__ == "__main__":
main()