Dears..kindly help to stop the Streamlit screen full refresh when user click button and sends the payload to rasa chatbot to get response.exactly when it comes to requests.post then full screen getting refreshed.I read the callback function and sessionstate but could not find solution for my case. this is part of code for my rasa chatbot ( the code is working and getting response no issue)..Thanks
def on_button_click(x):
update_chat_history("user", x)
payload = {"sender": "user", "message": x}
st.session_state.response = requests.post("http://localhost:5005/webhooks/rest/webhook",
json=payload)
payload_bot_reply=st.session_state.response.json()
if payload_bot_reply:
st.session_state.payload_bot_response = payload_bot_reply[0].get("text", "")
from here i call on_button_click
with st.chat_message("assistant"):
for i, assistant_response in enumerate(assistant_responses):
message_placeholder = st.empty()
full_response = ""
for chunk in assistant_response.split():
full_response += chunk + " "
time.sleep(0.05)
message_placeholder.markdown(full_response + "▌")
message_placeholder.markdown(full_response )
update_chat_history("assistant", full_response)
for button_info in st.session_state.button_info_list:
button_title = button_info.get("title", "")
payload = button_info.get("payload", "").lstrip("/")
if st.button(label=button_title, on_click=on_button_click, args=[payload]):
st.session_state.messages.append({"role": "assistant", "content":
st.session_state.payload_bot_response})