Resetting Number Input in Select Box on_change

Hello! I apologise in advance if this question has been asked before, but I was only able to find examples with buttons or radio buttons (nothing with a select box).

The concept is pretty simple:

I have a list of sentence clusters that I display in a select box. The sentences in each cluster are paginated (I display only 20 at a time) and there is a page selector at the bottom of the UI (Figure below).

What I’m trying to achieve is make the page number input revert to 1 whenever the selected item in the select box changes. As of now I’m trying to do it like this:

SELECT_PAGE_WIDGET_KEY = 'select_page_widget'
SELECT_CLUSTER_WIDGET = 'select_cluster_widget'

def change_cluster():
       SessionManagementHelper.set_cluster_table(on_cluster_selection_change(self.selected_cluster))
            if st.session_state.get(SELECT_PAGE_WIDGET_KEY):
                st.session_state[SELECT_PAGE_WIDGET_KEY] = 1

st.selectbox(
       label='Cluster', options=clusters_labels,  # this is a variable holding my cluster names
       key=SELECT_CLUSTER_WIDGET,
       on_change=change_cluster
)

And the page number input is defined below as:

st.number_input(
        label='Page:',
        key=SELECT_PAGE_WIDGET,
        max_value=num_of_pages,  # this is a variable holding the total number of pages
        min_value=1,
        value=1
)

At the moment however, my solution works but I get a Streamlit warning about session_state[SELECT_PAGE_WIDGET] being set via the SessionState API before being used in a widget. Any idea on what I’m doing wrong / how to fix this?