import streamlit as st if 'chat' not in st.session_state: st.session_state.chat = "A: Hello" def submit(): st.session_state.chat += f' \nB: {st.session_state.B}' st.session_state.chat += ' \nA: Some response.' # Clear the text input widget for convenience st.session_state.B = '' st.write(st.session_state.chat) st.text_input('B\'s Response', key='B', on_change=submit) # Define the scroll operation as a function and pass in something unique for each # page load that it needs to re-evaluate where "bottom" is js = f""" """ st.components.v1.html(js)