Not able to get the st.radio output to a variable

I am testing a text-2-sql chatbot application using streamlit locally in a dev container and having some issues in getting the output from st.radio button to a variable and process it conditionally.

So my requirement is as below-
Once the user submits his question the chat app will generate a sql and user feedback is request using st.radio button. If the SQL looks good then execute else don’t execute it on the database.

Below is my code

# # Feedback
options = ["", "Yes", "No"]
user_sql_feedback = st.chat_message("user")
# # # user_sql_feedback.write(f"Are you happy with the generated SQL code?")
with user_sql_feedback:
    #     with st.form('form'):
    #         feedback = st.radio(
    #             label='Are you happy with the generated SQL code?',
    #             options=options,
    #             index=None
    #         )
    #         submitted = st.form_submit_button('Submit')
    #         if submitted:

    #             st.session_state.feedback = feedback
    # if not st.session_state.feedback:
    #     if st.session_state.feedback == 'Yes':
    #         # df = run_sql_cached(sql=sql)
    #         clara_feedback["queryScore"] = 1
    #         print("***clara_feedback***")
    #         print(clara_feedback)
    #     elif st.session_state.feedback == "No":
    #         st.warning(
    #             "Sorry to hear that the SQL response is not as expected! This question will be sent to train the model. Please continue asking the question about your data!"
    #         )
    #         clara_feedback["queryScore"] = 0
    #         print("<<<clara_feedback>>>")
    #         print(clara_feedback)
    #     else:
    #         clara_feedback["queryScore"] = -1
    #         print("***clara_feedback***")
    #         print(clara_feedback)

    user_fbk = st.radio(
        label="Are you happy with the generated SQL code?",
        options=options,
        horizontal=True,
        key="user_fbk_key",
        index=0
        )
  if user_fbk == "Yes":
      # df = run_sql_cached(sql=sql)
      clara_feedback["queryScore"] = 1
      print("***clara_feedback***")
      print(clara_feedback)
  elif user_fbk == "No":
      st.warning(
          "Sorry to hear that the SQL response is not as expected! This question will be sent to train the model. Please continue asking the question about your data!"
      )
      clara_feedback["queryScore"] = 0
      print("<<<clara_feedback>>>")
      print(clara_feedback)
  else:
      clara_feedback["queryScore"] = -1
      print("***clara_feedback***")
      print(clara_feedback)

It always goes to the else condition even I am selecting yes or no. Need help on understanding why this is happening and what is error in my code.

Thanks!

After fixing an IndentationError and a NameError, your code works as expected for me.

can you please share the code you ran. There is no indentation error on my actual code.

Well, I can only help you to fix the code that I can see. This is your posted code, fixed:

import streamlit as st

clara_feedback = {}

# # Feedback
options = ["", "Yes", "No"]
user_sql_feedback = st.chat_message("user")
# # # user_sql_feedback.write(f"Are you happy with the generated SQL code?")
with user_sql_feedback:
    #     with st.form('form'):
    #         feedback = st.radio(
    #             label='Are you happy with the generated SQL code?',
    #             options=options,
    #             index=None
    #         )
    #         submitted = st.form_submit_button('Submit')
    #         if submitted:

    #             st.session_state.feedback = feedback
    # if not st.session_state.feedback:
    #     if st.session_state.feedback == 'Yes':
    #         # df = run_sql_cached(sql=sql)
    #         clara_feedback["queryScore"] = 1
    #         print("***clara_feedback***")
    #         print(clara_feedback)
    #     elif st.session_state.feedback == "No":
    #         st.warning(
    #             "Sorry to hear that the SQL response is not as expected! This question will be sent to train the model. Please continue asking the question about your data!"
    #         )
    #         clara_feedback["queryScore"] = 0
    #         print("<<<clara_feedback>>>")
    #         print(clara_feedback)
    #     else:
    #         clara_feedback["queryScore"] = -1
    #         print("***clara_feedback***")
    #         print(clara_feedback)

    user_fbk = st.radio(
        label="Are you happy with the generated SQL code?",
        options=options,
        horizontal=True,
        key="user_fbk_key",
        index=0
        )
    if user_fbk == "Yes":
      # df = run_sql_cached(sql=sql)
      clara_feedback["queryScore"] = 1
      print("***clara_feedback***")
      print(clara_feedback)
    elif user_fbk == "No":
      st.warning(
          "Sorry to hear that the SQL response is not as expected! This question will be sent to train the model. Please continue asking the question about your data!"
      )
      clara_feedback["queryScore"] = 0
      print("<<<clara_feedback>>>")
      print(clara_feedback)
    else:
      clara_feedback["queryScore"] = -1
      print("***clara_feedback***")
      print(clara_feedback)