Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,7 @@ openai.api_key = os.getenv("API_KEY")
|
|
| 12 |
# Streamlit app:
|
| 13 |
def main():
|
| 14 |
st.title("Tech Support Chatbot")
|
|
|
|
| 15 |
|
| 16 |
# Initialize or continue the session's conversation history
|
| 17 |
if 'history' not in st.session_state:
|
|
@@ -21,12 +22,12 @@ def main():
|
|
| 21 |
user_input = st.text_input("Tell us what's happening:", key="user_input")
|
| 22 |
|
| 23 |
# Submit button
|
| 24 |
-
if st.button("Submit")
|
| 25 |
if user_input: # Ensuring input is not empty
|
| 26 |
response = get_message(user_input)
|
| 27 |
display_conversation(user_input, response)
|
| 28 |
st.session_state.user_input = "" # Clear the input after submission
|
| 29 |
-
|
| 30 |
# Clear history button
|
| 31 |
if st.button("Clear History"):
|
| 32 |
st.session_state.history = []
|
|
@@ -39,7 +40,6 @@ def display_conversation(user_input, response):
|
|
| 39 |
st.markdown(f"<div style='background-color:#e1f5fe;padding:10px;border-radius:10px;'>{message}</div> ", unsafe_allow_html=True)
|
| 40 |
else:
|
| 41 |
st.markdown(f"<div style='background-color:#ffd7b5;padding:10px;border-radius:10px;'>{message}</div> ", unsafe_allow_html=True)
|
| 42 |
-
st.session_state.enter_pressed = False # Reset the enter trigger
|
| 43 |
|
| 44 |
def get_message(user_input):
|
| 45 |
context = """
|
|
|
|
| 12 |
# Streamlit app:
|
| 13 |
def main():
|
| 14 |
st.title("Tech Support Chatbot")
|
| 15 |
+
st.subheader("This is a demo of a tech support chatbot. We can build these into Slack or other messaging apps.")
|
| 16 |
|
| 17 |
# Initialize or continue the session's conversation history
|
| 18 |
if 'history' not in st.session_state:
|
|
|
|
| 22 |
user_input = st.text_input("Tell us what's happening:", key="user_input")
|
| 23 |
|
| 24 |
# Submit button
|
| 25 |
+
if st.button("Submit"):
|
| 26 |
if user_input: # Ensuring input is not empty
|
| 27 |
response = get_message(user_input)
|
| 28 |
display_conversation(user_input, response)
|
| 29 |
st.session_state.user_input = "" # Clear the input after submission
|
| 30 |
+
|
| 31 |
# Clear history button
|
| 32 |
if st.button("Clear History"):
|
| 33 |
st.session_state.history = []
|
|
|
|
| 40 |
st.markdown(f"<div style='background-color:#e1f5fe;padding:10px;border-radius:10px;'>{message}</div> ", unsafe_allow_html=True)
|
| 41 |
else:
|
| 42 |
st.markdown(f"<div style='background-color:#ffd7b5;padding:10px;border-radius:10px;'>{message}</div> ", unsafe_allow_html=True)
|
|
|
|
| 43 |
|
| 44 |
def get_message(user_input):
|
| 45 |
context = """
|