Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -79,6 +79,12 @@ def chatbot_response(user_input):
|
|
79 |
response = qa.run(user_input)
|
80 |
return response
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
# Create columns for logos
|
83 |
col1, col2, col3 = st.columns([2, 3, 2])
|
84 |
|
@@ -105,16 +111,18 @@ st.markdown("""
|
|
105 |
st.markdown('<h3 class="centered-text">🤖 AlteriaChat 🤖 </h3>', unsafe_allow_html=True)
|
106 |
st.markdown('<p class="centered-orange-text">"Votre Réponse à Chaque Défi Méthodologique "</p>', unsafe_allow_html=True)
|
107 |
|
108 |
-
# Input
|
109 |
with st.form(key='interaction_form'):
|
110 |
-
|
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 |
-
|
|
|
|
|
|
|
116 |
st.markdown("### Bot:")
|
117 |
-
st.text_area("", value=bot_response, height=600)
|
118 |
|
119 |
# Separate form for feedback submission
|
120 |
with st.form(key='feedback_form'):
|
@@ -129,8 +137,11 @@ if ask_button and user_input.strip():
|
|
129 |
|
130 |
if feedback_submit_button:
|
131 |
if comment.strip():
|
132 |
-
save_feedback(user_input, bot_response, rating, comment)
|
133 |
st.success("Thank you for your feedback!")
|
|
|
|
|
|
|
134 |
else:
|
135 |
st.warning("Please provide a comment before submitting feedback.")
|
136 |
|
|
|
79 |
response = qa.run(user_input)
|
80 |
return response
|
81 |
|
82 |
+
# Session state to hold user input and chatbot response
|
83 |
+
if 'user_input' not in st.session_state:
|
84 |
+
st.session_state.user_input = ""
|
85 |
+
if 'bot_response' not in st.session_state:
|
86 |
+
st.session_state.bot_response = ""
|
87 |
+
|
88 |
# Create columns for logos
|
89 |
col1, col2, col3 = st.columns([2, 3, 2])
|
90 |
|
|
|
111 |
st.markdown('<h3 class="centered-text">🤖 AlteriaChat 🤖 </h3>', unsafe_allow_html=True)
|
112 |
st.markdown('<p class="centered-orange-text">"Votre Réponse à Chaque Défi Méthodologique "</p>', unsafe_allow_html=True)
|
113 |
|
114 |
+
# Input form for user interaction
|
115 |
with st.form(key='interaction_form'):
|
116 |
+
st.session_state.user_input = st.text_input("You:", key="user_input_input")
|
|
|
117 |
ask_button = st.form_submit_button("Ask 📨") # Button to submit the question
|
118 |
|
119 |
+
if ask_button and st.session_state.user_input.strip():
|
120 |
+
st.session_state.bot_response = chatbot_response(st.session_state.user_input)
|
121 |
+
|
122 |
+
# Display the bot response if available
|
123 |
+
if st.session_state.bot_response:
|
124 |
st.markdown("### Bot:")
|
125 |
+
st.text_area("", value=st.session_state.bot_response, height=600)
|
126 |
|
127 |
# Separate form for feedback submission
|
128 |
with st.form(key='feedback_form'):
|
|
|
137 |
|
138 |
if feedback_submit_button:
|
139 |
if comment.strip():
|
140 |
+
save_feedback(st.session_state.user_input, st.session_state.bot_response, rating, comment)
|
141 |
st.success("Thank you for your feedback!")
|
142 |
+
# Clear the session state after submission
|
143 |
+
st.session_state.user_input = ""
|
144 |
+
st.session_state.bot_response = ""
|
145 |
else:
|
146 |
st.warning("Please provide a comment before submitting feedback.")
|
147 |
|