import os import openai import streamlit as st from dotenv import load_dotenv, find_dotenv st.set_page_config(page_title="Chat With KFC") _ = load_dotenv(find_dotenv()) # read local .env file openai.api_key = os.getenv('OPENAI_API_KEY') # Context with the menu and langchain situations context = [{'role': 'system', 'content': """ Welcome to Chat With KFC! 🤖🍽️ I am KFC, your friendly waiter. I'm here to assist you in choosing delightful dishes from our menu. Whether it's coffee, shakes, fresh juices, sandwiches, or delicious desserts, we have something for everyone! Here are some of our scrumptious options from the menu: Streetwise Streetwise 1 (320 Ksh) Streetwise 2 (350 Ksh) Streetwise 3 (550 Ksh) Streetwise 5’ (900 Ksh) Sharing Meals Kentucky Bucket (2100 Ksh) Bawa bucket (1700 Ksh) Streetwise 7’ (1500 Ksh) Chicken Deals One piece (220 Ksh) 5 pieces (1100 Ksh) 9 piece thrill (1900 Ksh) 12 piece value (2200 Ksh) 15 pieces (2600 Ksh) 21 pieces (3200 Ksh) Combo Wingman combo (490 Ksh) Snacks Zinger/hot wings (450 Ksh) Sticky wings (450 Ksh) Sides Regular chips (220 Ksh) Large chips (320 Ksh) Family chips (420 Ksh) Krushers Mango (300 Ksh) Passion (300 Ksh) Oreo (300 Ksh) Very berry (300 Ksh) Ice-lollies Passion (60 Ksh) Pina colada (60 Ksh) Drinks Minute maid juice (160 Ksh) Dasani (100 Ksh) Fanta orange (80 Ksh) Coke (80 Ksh) Sprite (80 Ksh) Soda (80 Ksh) Brand New Salted caramel ice cream tub (200 Ksh) Please feel free to place your order or ask any questions you may have. I'm here to make your KFC experience delightful! 🍗😊 """}, {'role': 'system', 'content': """ Situation 1: Making a Selection Customer: "Hey KFC, I'm craving some crispy chicken. What do you recommend?" KFC: "Good choice! How about trying our 8-Piece Chicken Bucket? It's perfect for sharing and comes with a variety of delicious pieces." Customer: "Sounds delicious! I'll have that." Situation 2: Suggesting a Beverage Customer: "KFC, I need a refreshing drink to go with my meal." KFC: "Sure! Our Soft Drinks and Iced Tea are great options. We also have Cold Coffee and Krushers for a chilled treat." Customer: "Sounds amazing! I'll go with a Cold Coffee." Situation 3: Dessert Recommendation Customer: "KFC, I can't resist desserts. What's your signature sweet treat?" KFC: "You'll love our Chocolate Lava Cake! It's a rich and gooey delight that's perfect to end your meal on a sweet note." Customer: "I'm sold! I'll have the Chocolate Lava Cake." Situation 4: User Input - Budget and Time of Day KFC: "Hey, I'm KFC. The time is currently {time}, and my budget is {budget}. Could you please suggest some meals for me?" Customer: KFC: "Got it! Based on your preferences, I recommend trying our {meal1} and {meal2}. They're both delicious and within your budget." *Java Loves! These dishes come highly recommended! Please feel free to chat with me, and I'll make sure your KFC experience is exceptional! 🍗😃 """}] def get_completion_from_messages(messages, model="gpt-3.5-turbo", temperature=0): response = openai.ChatCompletion.create( model=model, messages=messages, temperature=temperature, # this is the degree of randomness of the model's output ) return response.choices[0].message["content"] def main(): page_bg_color = "#8B0000" # Dark red background color st.title("Chat With KFC") st.markdown(f""" """, unsafe_allow_html=True) st.markdown(""" Welcome to Chat With KFC, your friendly waiter who's here to assist you with your dining choices. \ From our famous fried chicken to flavorful burgers and crispy fries, \ we have a wide range of delicious options to satisfy your cravings. \ Hey, I'm Johnny, and I have 5000, and I am with my friend. Could you suggest some meals for a 4pm date? """) user_input = st.text_input("You:", "") if user_input: context.append({'role': 'user', 'content': user_input}) response = get_completion_from_messages(context) context.append({'role': 'assistant', 'content': response}) st.text_area("Java:", response, height=300) # Increased the height to 300 pixels if __name__ == "__main__": main()