mery22 commited on
Commit
ab39ce5
1 Parent(s): edb146d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -107,27 +107,31 @@ st.markdown('<p class="centered-orange-text">"Votre Réponse à Chaque Défi Mé
107
 
108
  # Input and button for user interaction
109
  with st.form(key='interaction_form'):
 
110
  user_input = st.text_input("You:", key="user_input")
111
- submit_button = st.form_submit_button("Ask 📨")
112
 
113
- if submit_button and user_input.strip():
114
  bot_response = chatbot_response(user_input)
115
  st.markdown("### Bot:")
116
  st.text_area("", value=bot_response, height=600)
117
 
118
- # Feedback form within the same interaction form
119
  st.markdown("### Rate the response:")
120
  rating = st.slider("Select a rating:", min_value=1, max_value=5, value=1, key="rating")
121
 
122
  st.markdown("### Leave a comment:")
123
  comment = st.text_area("", key="comment")
124
 
125
- # Feedback submission handled in the same form
126
- if user_input.strip() and comment.strip():
127
- save_feedback(user_input, bot_response, rating, comment)
128
- st.success("Thank you for your feedback!")
129
- else:
130
- st.warning("Please provide both input and comment.")
 
 
 
131
 
132
  st.markdown("---")
133
  st.markdown("Collaboration is the key to success. Each question finds its answer, each challenge becomes an opportunity.")
 
107
 
108
  # Input and button for user interaction
109
  with st.form(key='interaction_form'):
110
+ # User input section
111
  user_input = st.text_input("You:", key="user_input")
112
+ ask_button = st.form_submit_button("Ask 📨") # Button to submit the question
113
 
114
+ if ask_button and user_input.strip():
115
  bot_response = chatbot_response(user_input)
116
  st.markdown("### Bot:")
117
  st.text_area("", value=bot_response, height=600)
118
 
119
+ # Feedback section within the same form
120
  st.markdown("### Rate the response:")
121
  rating = st.slider("Select a rating:", min_value=1, max_value=5, value=1, key="rating")
122
 
123
  st.markdown("### Leave a comment:")
124
  comment = st.text_area("", key="comment")
125
 
126
+ # Separate submit button for feedback
127
+ feedback_submit_button = st.form_submit_button("Submit Feedback")
128
+
129
+ if feedback_submit_button:
130
+ if comment.strip():
131
+ save_feedback(user_input, bot_response, rating, comment)
132
+ st.success("Thank you for your feedback!")
133
+ else:
134
+ st.warning("Please provide a comment before submitting feedback.")
135
 
136
  st.markdown("---")
137
  st.markdown("Collaboration is the key to success. Each question finds its answer, each challenge becomes an opportunity.")