File size: 4,898 Bytes
9b943ed
0f5cb95
9bc6f54
0f5cb95
20cf4ac
0f5cb95
9b943ed
c1fe981
 
 
 
 
 
 
 
 
 
53f2718
c1fe981
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a0ec8dd
 
 
 
 
 
 
 
53f2718
 
a0ec8dd
 
 
 
 
c1fe981
 
 
 
0f5cb95
3c4e2b2
7aa0365
 
0f5cb95
20cf4ac
 
 
3c4e2b2
9bc6f54
7aa0365
3c4e2b2
7aa0365
3c4e2b2
9bc6f54
 
 
906e7ee
 
a0ec8dd
27c320c
20cf4ac
19f9667
20cf4ac
3c4e2b2
 
19f9667
20cf4ac
 
19f9667
20cf4ac
 
 
 
 
 
 
19f9667
a0ec8dd
 
 
7aa0365
 
20cf4ac
7aa0365
3c4e2b2
 
 
 
0f5cb95
7aa0365
8946610
3c4e2b2
a0ec8dd
8946610
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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(
    """
    <style>
    .main-title {
        font-size: 2.5rem;
        color: #333;
        text-align: center;
        font-weight: bold;
    }
    .subtitle {
        font-size: 1.25rem;
        color: #555;
        text-align: center;
        margin-bottom: 2rem;
    }
    .chat-history {
        margin-bottom: 2rem;
    }
    .chat-box {
        padding: 1rem;
        border-radius: 10px;
        margin-bottom: 1rem;
        max-width: 80%;
    }
    .customer {
        background-color: #DCF8C6;
        color: #000;
        align-self: flex-end;
    }
    .bot {
        background-color: #E6E6E6;
        color: #000;
        align-self: flex-start;
    }
    .input-container {
        display: flex;
        align-items: center;
    }
    .input-field {
        flex: 1;
        margin-right: 10px;
    }
    .button {
        display: inline-block;
        padding: 10px 20px;
        background-color: #007BFF;
        color: #fff;
        border: none;
        border-radius: 5px;
        cursor: pointer;
        font-size: px;
        margin: 20px;
        text-align: center;
    }
    .button:hover {
        background-color: #0056b3;
    }
    </style>
    """,
    unsafe_allow_html=True
)

# Title and subtitle
st.markdown('<div class="main-title">THE CHEF STORY</div>', unsafe_allow_html=True)
st.markdown('<div class="subtitle">Where your cravings find a home</div>', 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'<div class="chat-box {class_name}">{message}</div>', 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()