namann007 commited on
Commit
9bc6f54
1 Parent(s): d3aafb9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -8
app.py CHANGED
@@ -1,9 +1,10 @@
1
- import streamlit as st
2
  from langchain_google_genai import ChatGoogleGenerativeAI
 
3
 
4
  st.set_page_config(page_title="THE CHEF STORY", layout="wide")
5
 
6
- # Styling the page
7
  st.markdown(
8
  """
9
  <style>
@@ -46,6 +47,20 @@ st.markdown(
46
  flex: 1;
47
  margin-right: 10px;
48
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  </style>
50
  """,
51
  unsafe_allow_html=True
@@ -59,24 +74,38 @@ def chef_bot(question, chat_history):
59
  history = "\n".join([f"{sender}: {message}" for sender, message in chat_history])
60
  prompt = (
61
  f"You are the chatbot for The Chef Story, a multi-cuisine restaurant chain known for its delicious food and vibrant folklore shows. "
62
- f"The Chef Story is located in various cities, providing online ordering and home delivery services with minimal charges of $3 within 4km of radius and addition of $1 for each km. "
63
  f"We offer a variety of cuisines, including Indian, Chinese, Italian, low-calorie options, kids' specials, and desserts, all priced in dollars. "
64
  f"Here's the current interaction history:\n{history}\nCustomer: {question}\nYou: "
65
  f"Always respond positively, providing detailed information about our menu, services, and special events. "
66
  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. "
67
- f"Welcome the customer warmly and offer a great experience at The Chef Story."
68
- f"Ask a separate question from customer if it's the birthday or weddind anniversary of any of his companions. If yes then offer a free cake to the group. "
69
- f"Ask a separate question from customer If he has rated the restaurant on the google, if yes then offer a coupon of 20% discount. "
70
  f"If it is a weekend, offer a free drink to the customer. "
71
  f"If the customer is visiting on weekends between 3 to 6 p.m., offer a free snack item."
72
- f"Highlight the above 4 offers in special bullet points"
73
- f'Ask the customer if he wants to play the quiz. Quiz would be related to unique cuisines of different countries in which you ask three questions to the customer along with the options. Ask questions one by one. If he answers all the three correctly then gift him a hamper. Mention this under the "fun activities" category'
74
  )
75
 
76
  llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["GOOGLE_API_KEY"])
77
  answer = llm.invoke(prompt).content
78
  return answer
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  if 'chat_history' not in st.session_state:
81
  st.session_state['chat_history'] = []
82
 
@@ -88,6 +117,10 @@ def handle_chat():
88
  st.session_state.chat_history.append(("Chef Story", bot_response))
89
  st.session_state['user_input'] = ""
90
 
 
 
 
 
91
  # Welcome message
92
  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.")
93
 
@@ -100,3 +133,6 @@ if st.session_state.chat_history:
100
  # Input field for user message
101
  st.text_input("How may I assist you today?", key="user_input", on_change=handle_chat, placeholder="Ask me anything...")
102
 
 
 
 
 
1
+ import streamlit as st
2
  from langchain_google_genai import ChatGoogleGenerativeAI
3
+ from datetime import datetime
4
 
5
  st.set_page_config(page_title="THE CHEF STORY", layout="wide")
6
 
7
+ # Page styling without using HTML
8
  st.markdown(
9
  """
10
  <style>
 
47
  flex: 1;
48
  margin-right: 10px;
49
  }
50
+ .quiz-button {
51
+ display: block;
52
+ margin: 0 auto;
53
+ padding: 10px 20px;
54
+ background-color: #007BFF;
55
+ color: #fff;
56
+ border: none;
57
+ border-radius: 5px;
58
+ cursor: pointer;
59
+ font-size: 16px;
60
+ }
61
+ .quiz-button:hover {
62
+ background-color: #0056b3;
63
+ }
64
  </style>
65
  """,
66
  unsafe_allow_html=True
 
74
  history = "\n".join([f"{sender}: {message}" for sender, message in chat_history])
75
  prompt = (
76
  f"You are the chatbot for The Chef Story, a multi-cuisine restaurant chain known for its delicious food and vibrant folklore shows. "
77
+ f"The Chef Story is located in various cities, providing online ordering and home delivery services with minimal charges. "
78
  f"We offer a variety of cuisines, including Indian, Chinese, Italian, low-calorie options, kids' specials, and desserts, all priced in dollars. "
79
  f"Here's the current interaction history:\n{history}\nCustomer: {question}\nYou: "
80
  f"Always respond positively, providing detailed information about our menu, services, and special events. "
81
  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. "
82
+ f"Welcome the customer warmly and offer a great experience at The Chef Story. "
83
+ f"If it's the birthday of any of the customer's companions, offer a free cake to the group. "
84
+ f"If the customer has rated the restaurant on the website, offer a coupon of 20% discount. "
85
  f"If it is a weekend, offer a free drink to the customer. "
86
  f"If the customer is visiting on weekends between 3 to 6 p.m., offer a free snack item."
87
+ f"Highlight the above 4 offers in bullet points and bold"
 
88
  )
89
 
90
  llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["GOOGLE_API_KEY"])
91
  answer = llm.invoke(prompt).content
92
  return answer
93
 
94
+ def generate_quiz():
95
+ quiz_prompt = (
96
+ "You are the chatbot for The Chef Story, a multi-cuisine restaurant chain. Generate a quiz related to unique cuisine items. "
97
+ "The quiz should contain three questions. If the customer answers all three questions correctly, they will get a special gift hamper. "
98
+ "Here are the three quiz questions:\n"
99
+ "1. What is the main ingredient in the Indian dish 'Paneer Tikka'?\n"
100
+ "2. Which cuisine is 'Sushi' originally from?\n"
101
+ "3. What is the primary flavor of Italian 'Tiramisu' dessert?\n"
102
+ "Please answer the questions one by one."
103
+ )
104
+
105
+ llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["GOOGLE_API_KEY"])
106
+ quiz = llm.invoke(quiz_prompt).content
107
+ return quiz
108
+
109
  if 'chat_history' not in st.session_state:
110
  st.session_state['chat_history'] = []
111
 
 
117
  st.session_state.chat_history.append(("Chef Story", bot_response))
118
  st.session_state['user_input'] = ""
119
 
120
+ def handle_quiz():
121
+ quiz = generate_quiz()
122
+ st.session_state.chat_history.append(("Chef Story", quiz))
123
+
124
  # Welcome message
125
  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.")
126
 
 
133
  # Input field for user message
134
  st.text_input("How may I assist you today?", key="user_input", on_change=handle_chat, placeholder="Ask me anything...")
135
 
136
+ # Quiz button
137
+ if st.button("Start Quiz", key="quiz_button"):
138
+ handle_quiz()