So I have the following streamlit code inside my TopicGenerator class. It shows the topics retrieved from my backend server. I want to be able to regenerate the topics, so to do that I have a button that creates a new TopicGenerator class. I have also created all my elements within self.empy(), so that when the “Regenerate” button is pressed, everything gets removed:
with self.container.container():
self.selected_topic = st.radio("Select a topic", self.topics, key=self.id + self.seed)
if self.selected_topic:
self.change_topic()
if st.button("Regenerate"):
st.session_state["topic_generator"].empty()
time.sleep(0.4)
new_data = initial_response(seed=key_button_topic)
st.session_state["topic_generator"] = TopicGeneration(new_data, inc=self.inc+1)
if st.button("Choose Topic"):
st.write(st.session_state)
st.write(st.session_state.selected_topic)
This gives me an error right away:
And another one after (probably when my initial_response method finishes calling, the server takes about 10sec to respond):
Guessing my issue is with trying to delete the button that is itself calling the empty method…?