Chatbot FrontEnd

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)
            user_input = " "
        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__":

Hey @Nourhane_Jneid,

Thanks for sharing your question with the community!

Can you double-check that you’ve posted a runnable code snippet? When I run your app I get the following error because the method chatbot_response is not defined:

NameError: name 'chatbot_response' is not defined
File "/opt/homebrew/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/", line 565, in _run_script
    exec(code, module.__dict__)
File "/Users/cfrasca/Desktop/apps/uber-example/", line 30, in <module>
File "/Users/cfrasca/Desktop/apps/uber-example/", line 17, in main
    response = chatbot_response(user_input)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.