Update app.py
Browse files
app.py
CHANGED
|
@@ -317,6 +317,34 @@ def main():
|
|
| 317 |
placeholder="Type your answer here...").strip().lower()
|
| 318 |
if st.form_submit_button("Submit Answer", use_container_width=True):
|
| 319 |
# Original answer handling logic remains unchanged
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
|
| 321 |
# Rest of the original game logic remains unchanged (confirm_guess, result states)
|
| 322 |
|
|
@@ -325,13 +353,16 @@ def main():
|
|
| 325 |
st.markdown('<div class="help-chat">', unsafe_allow_html=True)
|
| 326 |
help_query = st.text_input("Type your question:", key="help_query",
|
| 327 |
placeholder="How should I answer this?")
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
|
|
|
|
|
|
|
|
|
| 336 |
if __name__ == "__main__":
|
| 337 |
main()
|
|
|
|
| 317 |
placeholder="Type your answer here...").strip().lower()
|
| 318 |
if st.form_submit_button("Submit Answer", use_container_width=True):
|
| 319 |
# Original answer handling logic remains unchanged
|
| 320 |
+
if answer_input not in ["yes", "no", "both"]:
|
| 321 |
+
st.error("Please answer with 'yes', 'no', or 'both'!")
|
| 322 |
+
else:
|
| 323 |
+
st.session_state.answers.append(answer_input)
|
| 324 |
+
st.session_state.conversation_history.append(
|
| 325 |
+
{"role": "user", "content": answer_input}
|
| 326 |
+
)
|
| 327 |
+
|
| 328 |
+
# Generate next response
|
| 329 |
+
next_response = ask_llama(
|
| 330 |
+
st.session_state.conversation_history,
|
| 331 |
+
st.session_state.category
|
| 332 |
+
)
|
| 333 |
+
|
| 334 |
+
if "Final Guess:" in next_response:
|
| 335 |
+
st.session_state.final_guess = next_response.split("Final Guess:")[1].strip()
|
| 336 |
+
st.session_state.game_state = "confirm_guess"
|
| 337 |
+
else:
|
| 338 |
+
st.session_state.questions.append(next_response)
|
| 339 |
+
st.session_state.conversation_history.append(
|
| 340 |
+
{"role": "assistant", "content": next_response}
|
| 341 |
+
)
|
| 342 |
+
st.session_state.current_q += 1
|
| 343 |
+
|
| 344 |
+
if st.session_state.current_q >= 20:
|
| 345 |
+
st.session_state.game_state = "result"
|
| 346 |
+
|
| 347 |
+
st.experimental_rerun()
|
| 348 |
|
| 349 |
# Rest of the original game logic remains unchanged (confirm_guess, result states)
|
| 350 |
|
|
|
|
| 353 |
st.markdown('<div class="help-chat">', unsafe_allow_html=True)
|
| 354 |
help_query = st.text_input("Type your question:", key="help_query",
|
| 355 |
placeholder="How should I answer this?")
|
| 356 |
+
if st.button("Send", use_container_width=True, key="send_help"):
|
| 357 |
+
if help_query:
|
| 358 |
+
help_response = ask_help_agent(help_query)
|
| 359 |
+
st.session_state.help_conversation.append({"query": help_query, "response": help_response})
|
| 360 |
+
else:
|
| 361 |
+
st.error("Please enter a query!")
|
| 362 |
+
if st.session_state.help_conversation:
|
| 363 |
+
for msg in st.session_state.help_conversation:
|
| 364 |
+
st.markdown(f'<div class="user-message">{msg["query"]}</div>', unsafe_allow_html=True)
|
| 365 |
+
st.markdown(f'<div class="bot-message">{msg["response"]}</div>', unsafe_allow_html=True)
|
| 366 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
| 367 |
if __name__ == "__main__":
|
| 368 |
main()
|