import streamlit as st import google.generativeai as genai import os from dotenv import load_dotenv # Configure the generative model load_dotenv() genai.configure(api_key=os.getenv('GOOGLE_API_KEY')) # Set page configuration st.set_page_config( page_title="Minerva Interactive Cookbook", page_icon="/logo.png", layout="wide", ) # Logo image st.image("logo.png", width=135) # title st.title('Minerva Interactive Cookbook') st.write("Welcome to MIC! Use the dropdown menus to generate custom recipes. :cooking: (it takes about 15s to load)") # Define the list of dropdown options for each category rotation_city = ["San Fransisco", "Tokyo", "Seoul", "Taipei", "Hyderabad", "Buenos Aires", "Berlin"] course_options = ["Breakfast", "Appetizer", "Main Course", "Soup", "Salad", "Dessert"] portion_options = ["1 person", "2 people", "3 people", "4 people", "5 people", "10 people"] diet_options = ["No Restrictions", "Gluten-Free", "Halal", "Kosher", "Pescatarian", "Vegetarian", "Vegan"] cooking_difficulty = ["Super Easy", "Easy", "Medium", "Hard"] spice_options = ["No Spice", "Mild", "Medium", "Spicy"] calorie_level = ["Low Calorie", "Medium Calorie", "High Calorie"] # Create the dropdown boxes city = st.selectbox("City:", [""] + rotation_city) course = st.selectbox("Course:", [""] + course_options) portion = st.selectbox("Portion:", [""] + portion_options) diet = st.selectbox("Diet (optional):", [""] + diet_options) difficulty = st.selectbox("Difficulty (optional):", [""] + cooking_difficulty) spice = st.selectbox("Spice (optional):", [""] + spice_options) calorie = st.selectbox("calorie (optional):", [""] + calorie_level) # Text input for additional requests extra_requests = st.text_input("Optional Requests (e.g., no onions, high fiber):") # error handling if "" in [city, course, portion]: st.error("Please select a value for following fields: City, Course, and Portion.") st.stop() # define model model = genai.GenerativeModel('gemini-1.5-pro-latest') chat = model.start_chat(history=[]) # Button to trigger recipe generation if st.button('Find Recipes'): # Use the generative model to get recipe information prompt = f"Generate 3 recipes that are available in {city}, for {course} and for {portion}." prompt += """The recipies dont necessarily have to belong to the cousine of the stated city, the ingredients just have to be easy to find there. Just give at least one local dish. Change currencies by city. Include ingredient quantities and their prices. The output should be in this example format: Recipes --------- **Vegetable Yakisoba** - A flavorful lentil and vegetable soup with a hint of spice and sweetness. Ingredients: - 250g Yakisoba Noodles: $2.50 - 1 small head Cabbage, shredded: $1.20 - 2 large Carrots, julienned: $0.80 - 1 Red Bell Pepper, sliced: $0.75 - 1 Yellow Bell Pepper, sliced: $0.75 - 1 large Onion, sliced: $0.70 - 200g Mushrooms, sliced: $2.30 - 1/2 cup Soy Sauce: $1.80 - 2 tbsp Rice Vinegar: $1.50 **Total Estimated Price:** $12.30 Instructions: 1. Pressure cook the soaked moong dal until soft. 2. In a pan, heat ghee/oil and add cumin seeds. Once they splutter. --------- .... and so on""" if diet: prompt += f"It should be suitable for a {diet} diet." if difficulty: prompt += f"It should have a cooking difficulty of {difficulty}." if spice: prompt += f"It should have a spice level of {spice}." if calorie: prompt += f"It should have a calorie level of {calorie}." if extra_requests: prompt += f"Additionally, {extra_requests}" response = chat.send_message(prompt) st.write(response.text) # background image st.image("minerva.png")