Best Practices for Building GenAI Apps with Streamlit

Hi Jessica, are there tutorials on how we can clear or refresh the ‘chat_input’ contents after a series of exchanges between a user and a LLM?

I have tried the clear_chat_history solution and the chat texts are still shown in the chat_input box.
I was wondering whether there is a way to remove the markdown and ‘write’ text from the chat_input box.

eg

def clear_chat_history():
    st.session_state.messages = []  # Clear the message history


if prompt := st.chat_input("Say something"):
    st.session_state.messages.append({"role": "user", "content": prompt})
    # Display user message in chat message container
    with st.chat_message("user"):
        st.markdown(prompt)

    with st.chat_message("model"):
        response = st.session_state.chat_session.send_message(prompt)
        response_text = response.candidates[0].content.parts[0].text
        st.write(response_text)

    st.session_state.messages.append({"role": "model", "content": response_text})
    st.button("Clear History", on_click=clear_chat_history)