Multipage chatbot reset

I am creating a multipage chatbot application using streamlit.

Each page is a separate chatbot referring a separate vector database. However, when navigating between the pages, the chats do not refresh between each page and the conversation continues from the context of the previous page.

I would like to perform the following function if the page is changed to reset the session state of the chat.

if "messages" not in st.session_state.keys(): # Initialize the chat messages history
    st.session_state.messages = [
        {"role": "assistant", "content": "Ask me a question!"}
    ]

Is there any way to do this? Thanks.

Hi @Mir_Jibraan_Hussain

You can try changing the session state variable name, which in your case is messages, to something else so that each of the different chatbot uses a different variable.

1 Like

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