How to avoid rerun of script in Streamlit whicle clicking button

st.session_state.suggestions = get_suggestions(user_query, api_key, model_name, model_params)
logging.info(f"Suggestions for initial user query are {st.session_state.suggestions}“)
while st.session_state.suggestions:
for suggestion in st.session_state.suggestions:
try:
if st.button(suggestion, key = f"suggestion_selection_{uuid.uuid4()}”):
st.session_state.next_selected = suggestion
print(f"Initial suggestion Selected is {suggestion} and type is {type(suggestion)}“)
handle_button_click(suggestion, session_state_dict)
print(f"Session State Next Selected is {st.session_state.next_selected}”)
break # Exit loop after handling the click
except:
break
else:
# If no button was clicked, break the outer loop
break

In the above code snippet, when we choose button, it will still process the user query.
it is actually a chat bot which need to suggest questions to user based on previous queries.