A Regenerate Response Button for ChatBot

Hi, I have a simple ChatBot code that basically goes like this:

for message in st.session_state.messages:
        with st.chat_message(message["role"]):
            st.markdown(message["content"], unsafe_allow_html=True)
if prompt := st.chat_input("Type your question here..."):
      st.session_state.messages.append({"role": "user", "content": prompt})
  
       with st.chat_message("user"):
              st.markdown(f'<div class="user-message">{prompt}</div>', 
                                           unsafe_allow_html=True)
            
       if intent == "Metric":
                response_prompt = {
                "role": "user",
                "content": (
                    f"This is the session's conversation history so far: {st.session_state.messages}\n\n"
                    f"User's current question: {prompt}\n\n"
                    f"These are the filters applied: {updated_filters}\n\n"
                    "Answer the user's metric-based question using only the metrics provided."
                )
            }

        else: 
              response_prompt = {
                "role": "user",
                "content": (
                    f"This is the session's conversation history so far: {st.session_state.messages}\n\n"
                    f"User's current question: {prompt}\n\n"
                    f"These are the filters applied: {updated_filters}\n\n"
                    "Answer the user's non-metric-based question using only the metrics provided."
                )
            }


with st.chat_message("assistant"):
            stream = client.chat.completions.create(
                model=st.session_state["openai_model"],
                messages=[system_message, response_prompt],
                stream=True,
                temperature=0.7,
            )
            response = st.write_stream(stream)
            st.session_state.messages.append({"role": "assistant", "content": response})

Now my question is I’d like to add a button that appears after the AI’s response is streamed which says Regenerate Answer and it should ideally ask the AI for another response or a better response. This is what I have so far, but it doesn’t seem to work and doesn’t refresh or regenerate a new answer even though its adding to a similar project:

if st.button("Regenerate Answer 🔄"):
            st.session_state.messages.append(
                {"role": "user", "content": "User requested a new response as they were not satisfied with the previous one."}
            )

            response_prompt["content"] += "\nThe user has requested a fresh perspective. Rephrase or provide a different angle."

            with st.chat_message("assistant"):
                stream = client.chat.completions.create(
                    model=st.session_state["openai_model"],
                    messages=[system_message, response_prompt], 
                    stream=True,
                    temperature=0.9,  
                )
                response = st.write_stream(stream)

                st.session_state.messages.append({"role": "assistant", "content": response})
            for message in st.session_state.messages:
                with st.chat_message(message["role"]):
                    st.markdown(message["content"], unsafe_allow_html=True)