create a chatbot that can be use to help mentor employees
To upload files, please first save the app
import streamlit as st
import random
import time
# Streamed response emulator
def response_generator():
responses = [
"I'm here to help you with your professional growth. What would you like to discuss?",
"Mentoring can provide valuable insights. Do you have any specific questions?",
"Feel free to share your challenges, and I'll do my best to assist you!",
]
response = random.choice(responses)
for word in response.split():
yield word + " "
time.sleep(0.05)
st.title("Employee Mentoring Chatbot")
# Initialize chat history
if "messages" not in st.session_state:
st.session_state.messages = []
# Display chat messages from history on app rerun
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])
# Accept user input
if prompt := st.chat_input("How can I help you today?"):
# Add user message to chat history
st.session_state.messages.append({"role": "user", "content": prompt})
# Display user message in chat message container
with st.chat_message("user"):
st.markdown(prompt)
# Display assistant response in chat message container
with st.chat_message("assistant"):
response = st.write_stream(response_generator())
# Add assistant response to chat history
st.session_state.messages.append({"role": "assistant", "content": response})
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?