Streamlit select box not retaining selected values and its inconsisting

Hi ,
I am trying to update select box values with rest call, and trying to select one item , but its working strangely. not retaining selected value.

def retrieve_indices():

indices ="").json()

return indices

#select box
st.sidebar.subheader(“you can choose one from below”, )

st.sidebar.selectbox(“select one existing document”, options=retrieve_indices())

I have tried multiple ways but none of them worked. any help would highly appreicated.

You can see weird behavior here, selected value is not consistent