1 - Why do the questions not disappear after the execution of the answers?
How to fix this issue?
2- How to change the avatars
3- how to make the chat_history above the textbox
Code :
if 'past' not in st.session_state:
st.session_state.past = []
if 'generated' not in st.session_state:
st.session_state.generated = []
def main():
placeholder = st.empty()
with placeholder.container():
# User input text box
user_input = st.text_input("User Input")
if user_input:
response = chatbot_response(user_input)
st.session_state.past.append(user_input)
st.session_state.generated.append(response)
user_input = " "
else:
print("please enter a message")
if st.session_state['generated']:
for i in range(len(st.session_state['generated'])-1, -1, -1):
message(st.session_state["generated"][i], key=str(i))
message(st.session_state['past'][i], is_user=True, key=str(i) + '_user')
if __name__ == "__main__":
main()