Thomas-jared/Order-java-bot.1.1
0
1import os2import openai3import streamlit as st4from dotenv import load_dotenv, find_dotenv5 6st.set_page_config(page_title="Chat With Java")7 8_ = load_dotenv(find_dotenv()) # read local .env file9openai.api_key = os.getenv('OPENAI_API_KEY')10 11# Context with the menu and langchain situations12context = [{'role': 'system', 'content': """13Welcome to Chat With Java! 🤖🍽️14 15I am Java, your friendly waiter. I'm here to assist you in choosing delightful dishes from our menu.16Whether it's coffee, shakes, fresh juices, sandwiches, or delicious desserts, we have something for everyone!17 18Here are some of our scrumptious options from the menu:19 20 21COFFEE & ESPRESSO:22Single Double Triple23House Coffee * 190 230 26024Espresso 190 230 26025Macchiato 200 240 27026Americano 200 250 29027Cappuccino * 250 300 34028Caffè Latte 270 320 34029Mocha 290 350 39030Peppermint Mocha 290 350 39031Malindi Macchiato 290 350 39032Caramel Macchiato 300 350 39033Vanilla Latte 310 350 39034 35JAVA SHAKES:36Classic 47037Vanilla * | Chocolate | Mango | Strawberry38Gourmet 49039Choc Chip Cookie | Tropical Mix40Next Level Shakes 52041Salted Caramel | Double Espresso | Double Mocha42 43ICED BEVERAGES:44Iced Tea | Iced Lemon & Ginger | Iced Herbal Tea 27045Iced Arnold Palmer (1/2 iced tea & 1/2 lemonade) 31046Iced Tea with Fresh Juice 34047Iced Coffee 27048Iced Latte | Iced Vanilla Latte 36049Iced Mocha 37050Iced Malindi Macchiato | Iced Caramel Macchiato 37051 52SODA & WATER:53Soda 16054Diet Soda 19055Mineral Water (Still) 500ml 18056Mineral Water (Still) 1000ml 27057Mineral Water (Sparkling) 500ml 20058 59FRESH JUICES & SMOOTHIES:60Minty Pineade 270|37061Pineapple | Orange | Mango | Passion 280|36062Green Smoothie ♥ 42063Baby spinach, mango, pineapple, ginger, lemon juice, banana, celery64Tropical Thunder Mango, passion, banana, pawpaw 42065 66BREAKFAST:67Health Kick:68Fruit Salad ♥ 39069Fruit Salad with yogurt, honey and nuts ♥ * 50070Hot Oatmeal Porridge with almonds, raisins & brown sugar ♥71Half Serve|Full Serve 230|47072Homemade Granola ♥ 270|53073with milk or yogurt and choice of honey or strawberries74 75Sweet Tooth:76Pancakes:77Single fluffy homemade pancake with butter & syrup 29078Classic Three medium, fluffy homemade pancakes served with butter & syrup 63079+ Served with your choice of bacon or sausage 74080and a small side of freshly-cut fruit salad81 82SANDWICHES:83Classic Sandwiches:84Avocado, Cheese & Tomato ♥ 53085BBQ Chicken Club 59086Bacon, Lettuce & Tomato (BLT) 59087Chicken & Cheese * 59088Grilled Veggie Sandwich with red pepper spread 75089Grilled Chicken & Sundried Tomato 87090 91QUICK BITES:92Soup of the Day 47093 94DESSERTS:95Gourmet Gelato Ice Cream:96Double Dish | Triple Dish 330|43097Vanilla | Chocolate | Strawberry |98Chocolate Chip Cookie | Fior di Latte | Salted Caramel99 100Cakes:101Black Forest Cake * 400102Chocolate Fudge Cake * 400103Carrot Cake * 400104Seasonal Special Cake (Please ask your server) 400105Salted Caramel Cake 400106 107*Java Loves! These items come highly recommended!108 109Please feel free to place your order or ask any questions you may have. I'm here to make your pizza experience delightful! 🍕😊110 111Please feel free to place your order or ask any questions. I'm here to make your dining experience enjoyable! 😊112"""}, {'role': 'system', 'content': """113Situation 1: Making a Selection114 115Customer: "Hey Java, I'm in the mood for a savory breakfast. What do you recommend?"116Java: "Good choice! How about trying our Grilled Veggie Sandwich with red pepper spread? It's a delightful combination of flavors."117Customer: "Sounds delicious! I'll have that."118 119Situation 2: Suggesting a Beverage120 121Customer: "Java, I need a refreshing drink to beat the heat."122Java: "Sure! Our Tropical Thunder smoothie is perfect for that. It's a delightful blend of mango, passion fruit, and banana."123Customer: "Sounds amazing! I'll go with that."124 125Situation 3: Dessert Recommendation126 127Customer: "Java, I can't resist desserts. What's your signature sundae?"128Java: "You'll love our Hot Fudge Sundae! It's a rich and decadent treat with homemade toppings."129Customer: "I'm sold! I'll have the Hot Fudge Sundae."130 131Situation 4: User Input - Budget and Time of Day132 133Java: "Hey, I'm Java. The time is currently {time}, and my budget is {budget}. Could you please suggest some meals for me?"134Customer: <User inputs their time and budget>135Java: "Got it! Based on your preferences, I recommend trying our {meal1} and {meal2}. They're both delicious and within your budget."136 137*Java Loves! These dishes come highly recommended!138 139Please feel free to chat with me, and I'll make sure your dining experience is exceptional! 🍽️😃140"""}]141 142def get_completion_from_messages(messages, model="gpt-3.5-turbo", temperature=0):143 response = openai.ChatCompletion.create(144 model=model,145 messages=messages,146 temperature=temperature, # this is the degree of randomness of the model's output147 )148 return response.choices[0].message["content"]149 150def main():151 page_bg_color = "#8B0000" # Dark red background color152 153 st.title("Chat With Java")154 st.markdown(f"""155 <style>156 .reportview-container {{157 background-color: {page_bg_color};158 color: white;159 }}160 .sidebar .sidebar-content {{161 background-color: {page_bg_color};162 }}163 </style>164 """, unsafe_allow_html=True)165 166 st.markdown("""167 Welcome to Chat With Java, your friendly waiter who's here to assist you with your dining choices. \168 From beverages to mouthwatering dishes and delightful desserts, \169 Hey im Johnny i have 5000, and i am with my friend, could you suggest some meals for a 4pm date?170 """)171 172 user_input = st.text_input("You:", "")173 174 if user_input:175 context.append({'role': 'user', 'content': user_input})176 response = get_completion_from_messages(context)177 context.append({'role': 'assistant', 'content': response})178 st.text_area("Java:", response, height=300) # Increased the height to 300 pixels179 180if __name__ == "__main__":181 main()182 