ibrahim yıldız commited on
Commit
c9166c4
·
verified ·
1 Parent(s): fffcce6

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +102 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import google.generativeai as genai
3
+ import os
4
+ from dotenv import load_dotenv
5
+
6
+ # Configure the generative model
7
+ load_dotenv()
8
+ genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))
9
+
10
+ # Set page configuration
11
+ st.set_page_config(
12
+ page_title="Minerva Interactive Cookbook",
13
+ page_icon="/logo.png",
14
+ layout="wide",
15
+ )
16
+
17
+ # Logo image
18
+ st.image("logo.png", width=135)
19
+
20
+ # title
21
+ st.title('Minerva Interactive Cookbook')
22
+ st.write("Welcome to MIC! Use the dropdown menus to generate custom recipes. :cooking:")
23
+
24
+
25
+ # Define the list of dropdown options for each category
26
+ rotation_city = ["San Fransisco", "Tokyo", "Seoul", "Taipei", "Hyderabad", "Buenos Aires", "Berlin"]
27
+ course_options = ["Breakfast", "Appetizer", "Main Course", "Soup", "Salad", "Dessert"]
28
+ portion_options = ["1 person", "2 people", "3 people", "4 people", "5 people", "10 people"]
29
+ diet_options = ["No Restrictions", "Gluten-Free", "Halal", "Kosher", "Pescatarian", "Vegetarian", "Vegan"]
30
+ cooking_difficulty = ["Super Easy", "Easy", "Medium", "Hard"]
31
+ spice_options = ["No Spice", "Mild", "Medium", "Spicy"]
32
+ calorie_level = ["Low Calorie", "Medium Calorie", "High Calorie"]
33
+
34
+
35
+
36
+ # Create the dropdown boxes
37
+ city = st.selectbox("City:", [""] + rotation_city)
38
+ course = st.selectbox("Course:", [""] + course_options)
39
+ portion = st.selectbox("Portion:", [""] + portion_options)
40
+ diet = st.selectbox("Diet (optional):", [""] + diet_options)
41
+ difficulty = st.selectbox("Difficulty (optional):", [""] + cooking_difficulty)
42
+ spice = st.selectbox("Spice (optional):", [""] + spice_options)
43
+ calorie = st.selectbox("calorie (optional):", [""] + calorie_level)
44
+ # Text input for additional requests
45
+ extra_requests = st.text_input("Optional Requests (e.g., no onions, high fiber):")
46
+
47
+
48
+
49
+ # error handling
50
+ if "" in [city, course, portion]:
51
+ st.error("Please select a value for following fields: City, Course, and Portion.")
52
+ st.stop()
53
+
54
+
55
+ # define model
56
+ model = genai.GenerativeModel('gemini-1.5-pro-latest')
57
+ chat = model.start_chat(history=[])
58
+
59
+
60
+ # Button to trigger recipe generation
61
+ if st.button('Find Recipes'):
62
+
63
+ # Use the generative model to get recipe information
64
+ prompt = f"Generate 3 recipes that are available in {city}, for {course} and for {portion}."
65
+ prompt += """The recipies dont necessarily have to belong to the cousine of the stated city,
66
+ the ingredients just have to be easy to find there. Just give at least one local dish. Change currencies by city.
67
+ Include ingredient quantities and their prices. The output should be in this example format:
68
+ Recipes
69
+ ---------
70
+ **Vegetable Yakisoba** - A flavorful lentil and vegetable soup with a hint of spice and sweetness.
71
+ Ingredients:
72
+ - 250g Yakisoba Noodles: $2.50
73
+ - 1 small head Cabbage, shredded: $1.20
74
+ - 2 large Carrots, julienned: $0.80
75
+ - 1 Red Bell Pepper, sliced: $0.75
76
+ - 1 Yellow Bell Pepper, sliced: $0.75
77
+ - 1 large Onion, sliced: $0.70
78
+ - 200g Mushrooms, sliced: $2.30
79
+ - 1/2 cup Soy Sauce: $1.80
80
+ - 2 tbsp Rice Vinegar: $1.50
81
+ **Total Estimated Price:** $12.30
82
+ Instructions:
83
+ 1. Pressure cook the soaked moong dal until soft.
84
+ 2. In a pan, heat ghee/oil and add cumin seeds. Once they splutter.
85
+ ---------
86
+ .... and so on"""
87
+ if diet:
88
+ prompt += f"It should be suitable for a {diet} diet."
89
+ if difficulty:
90
+ prompt += f"It should have a cooking difficulty of {difficulty}."
91
+ if spice:
92
+ prompt += f"It should have a spice level of {spice}."
93
+ if calorie:
94
+ prompt += f"It should have a calorie level of {calorie}."
95
+ if extra_requests:
96
+ prompt += f"Additionally, {extra_requests}"
97
+
98
+ response = chat.send_message(prompt)
99
+ st.write(response.text)
100
+
101
+ # background image
102
+ st.image("minerva.png")
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ google-generativeai
2
+ python-dotenv
3
+ streamlit