Update app.py
Browse files
app.py
CHANGED
@@ -193,7 +193,7 @@ def main():
|
|
193 |
|
194 |
with st.form("answer_form"):
|
195 |
answer_input = st.text_input("Your answer (yes/no):").strip().lower()
|
196 |
-
|
197 |
if st.form_submit_button("Submit"):
|
198 |
if answer_input not in ["yes", "no"]:
|
199 |
st.error("Please answer with 'yes' or 'no'!")
|
@@ -203,12 +203,12 @@ def main():
|
|
203 |
st.session_state.conversation_history.append(
|
204 |
{"role": "user", "content": answer_input}
|
205 |
)
|
206 |
-
|
207 |
# Check if we've reached max questions
|
208 |
if st.session_state.current_q >= 19: # 0-based index
|
209 |
st.session_state.game_state = "result"
|
210 |
else:
|
211 |
-
# Generate next question
|
212 |
next_question = ask_llama(
|
213 |
st.session_state.conversation_history,
|
214 |
st.session_state.category
|
@@ -218,7 +218,6 @@ def main():
|
|
218 |
{"role": "assistant", "content": next_question}
|
219 |
)
|
220 |
st.session_state.current_q += 1
|
221 |
-
|
222 |
st.rerun()
|
223 |
|
224 |
# Result screen
|
|
|
193 |
|
194 |
with st.form("answer_form"):
|
195 |
answer_input = st.text_input("Your answer (yes/no):").strip().lower()
|
196 |
+
|
197 |
if st.form_submit_button("Submit"):
|
198 |
if answer_input not in ["yes", "no"]:
|
199 |
st.error("Please answer with 'yes' or 'no'!")
|
|
|
203 |
st.session_state.conversation_history.append(
|
204 |
{"role": "user", "content": answer_input}
|
205 |
)
|
206 |
+
|
207 |
# Check if we've reached max questions
|
208 |
if st.session_state.current_q >= 19: # 0-based index
|
209 |
st.session_state.game_state = "result"
|
210 |
else:
|
211 |
+
# Generate next question only after answer is submitted
|
212 |
next_question = ask_llama(
|
213 |
st.session_state.conversation_history,
|
214 |
st.session_state.category
|
|
|
218 |
{"role": "assistant", "content": next_question}
|
219 |
)
|
220 |
st.session_state.current_q += 1
|
|
|
221 |
st.rerun()
|
222 |
|
223 |
# Result screen
|