Spaces:
Runtime error
Runtime error
from utils import (submit_prompt_to_gpt, | |
check_password) | |
system_content = { | |
"role": "system", | |
"content": """ | |
You are OrderBot, an automated service to collect orders for a Cloths selling retailer. \ | |
If the question is out of cloths order, just say that your question is out of scope of cloths order. \ | |
You first greet the customer, then collects the order, \ | |
and then asks if it's a pickup or delivery. \ | |
You wait to collect the entire order, then summarize it and check for a final \ | |
time if the customer wants to add anything else. \ | |
If it's a delivery, you ask for an address. \ | |
Finally you collect the payment.\ | |
Make sure to clarify all options, colors and sizes to uniquely \ | |
identify the item from the portfolio.\ | |
You respond in a short, very conversational friendly style. | |
At the end, ask them to press the Close Order button \ | |
The portfolio includes \ | |
Shirts: \ | |
T-shirt 12.95, 10.00, 7.00 \ | |
Polo Shirt 10.95, 9.25, 6.50 \ | |
Night Shirt 11.95, 9.75, 6.75 \ | |
Jean Jacket 11.95, 9.75, 6.75 \ | |
Hoodie 4.50, 3.50, 2.50\ | |
Pants: \ | |
Jean Pant 12.95, 10.00, 7.00 \ | |
Casual Pant 10.95, 9.25, 6.50 \ | |
Night Pant 11.95, 9.75, 6.75 \ | |
6-pocket Jean Pant 11.95, 9.75, 6.75 \ | |
Half pant 4.50, 3.50, 2.50\ | |
Accessories: \ | |
Ties 3.00, 2.00, 1.00 \ | |
Belts 3.00, 2.00, 1.00 \ | |
Watches 35.00 \ | |
""", | |
} | |
import streamlit as st | |
if check_password(): | |
st.title("Cloths Retailer : Order Bot") | |
st.markdown("Welcome to our cloth selling service. How can I assist you today?") | |
st.markdown("Feel free to ask me any question to order cloths.") | |
# Initialize chat history | |
if "messages" not in st.session_state: | |
st.session_state.messages = [system_content] | |
# Display chat messages from history on app rerun | |
for message in st.session_state.messages: | |
if message["role"] == "system": | |
pass | |
else: | |
with st.chat_message(message["role"]): | |
st.markdown(message["content"]) | |
# React to user input | |
if prompt := st.chat_input("Please type some thing here?"): | |
# Display user message in chat message container | |
with st.chat_message("user"): | |
st.markdown(prompt) | |
# Add user message to chat history | |
st.session_state.messages.append({"role": "user", "content": prompt}) | |
response = submit_prompt_to_gpt(st.session_state.messages) | |
# Display assistant response in chat message container | |
with st.chat_message("assistant"): | |
st.markdown(response) | |
# Add assistant response to chat history | |
st.session_state.messages.append({"role": "assistant", "content": response}) |