import streamlit as st from langchain_google_genai import ChatGoogleGenerativeAI from datetime import datetime st.set_page_config(page_title="THE CHEF STORY", layout="wide") # Page styling without using HTML st.markdown( """ """, unsafe_allow_html=True ) # Title and subtitle st.markdown('
THE CHEF STORY
', unsafe_allow_html=True) st.markdown('
Where your cravings find a home
', unsafe_allow_html=True) def chef_bot(question, chat_history): history = "\n".join([f"{sender}: {message}" for sender, message in chat_history]) prompt = ( f"You are the chatbot for The Chef Story, a multi-cuisine restaurant chain known for its delicious food and vibrant folklore shows. " f"The Chef Story is located in various cities, providing online ordering and home delivery services with minimal charges. " f"We offer a variety of cuisines, including Indian, Chinese, Italian, low-calorie options, kids' specials, and desserts, all priced in dollars. " f"Here's the current interaction history:\n{history}\nCustomer: {question}\nYou: " f"Always respond positively, providing detailed information about our menu, services, and special events. " f"Include brief descriptions and prices of the menu items when asked, and make sure to mention our website (www.thechefstory.com) for more information. " f"Welcome the customer warmly and offer a great experience at The Chef Story. " f"If it's the birthday of any of the customer's companions, offer a free cake to the group. " f"If the customer has rated the restaurant on the website, offer a coupon of 20% discount. " f"If it is a weekend, offer a free drink to the customer. " f"If the customer is visiting on weekends between 3 to 6 p.m., offer a free snack item." f"Highlight the above 4 offers in bullet points and bold and small, cute emojis." f'For the first message of customer you always have to begin with "Welcome to the Chef Story. Discover the perfect blend of taste and ambiance at The Chef Story. Our passion for food and commitment to quality shine through in every dish. Join us for a culinary journey where exceptional flavors and warm, inviting service come together to create a dining experience like no other."' ) llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["GOOGLE_API_KEY"]) answer = llm.invoke(prompt).content return answer if 'chat_history' not in st.session_state: st.session_state['chat_history'] = [] def handle_chat(): user_input = st.session_state['user_input'] if user_input: bot_response = chef_bot(user_input, st.session_state.chat_history) st.session_state.chat_history.append(("Customer", user_input)) st.session_state.chat_history.append(("Chef Story", bot_response)) st.session_state['user_input'] = "" def generate_response(): handle_chat() # Welcome message st.markdown("Welcome to The Chef Story where culinary excellence meets folklore magic. We are thrilled to have you here. Hope you will enjoy your meal and have an amazing day.") # Display chat history if st.session_state.chat_history: for sender, message in st.session_state.chat_history: class_name = "customer" if sender == "Customer" else "bot" st.markdown(f'
{message}
', unsafe_allow_html=True) # Input field for user message st.text_input("How may I assist you today?", key="user_input", on_change=generate_response, placeholder="Ask me anything...") # Button for generating response # if st.button("Generate Response"): # generate_response()