Update app.py
Browse files
app.py
CHANGED
|
@@ -477,40 +477,41 @@ def main():
|
|
| 477 |
</div>
|
| 478 |
""", unsafe_allow_html=True)
|
| 479 |
|
| 480 |
-
#
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 489 |
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
for msg in st.session_state.help_conversation:
|
| 499 |
-
# User message
|
| 500 |
-
st.markdown(f"""
|
| 501 |
-
<div class="chat-message user-message">
|
| 502 |
-
<div class="message-content">{msg['query']}</div>
|
| 503 |
-
<div class="message-timestamp">You</div>
|
| 504 |
-
</div>
|
| 505 |
-
""", unsafe_allow_html=True)
|
| 506 |
-
|
| 507 |
-
# Assistant message
|
| 508 |
-
st.markdown(f"""
|
| 509 |
-
<div class="chat-message assistant-message">
|
| 510 |
-
<div class="message-content" style="color:#1e293b;">{msg['response']}</div>
|
| 511 |
-
<div class="message-timestamp">Assistant</div>
|
| 512 |
-
</div>
|
| 513 |
-
""", unsafe_allow_html=True)
|
| 514 |
# Guess confirmation screen using text input response
|
| 515 |
elif st.session_state.game_state == "confirm_guess":
|
| 516 |
st.markdown(f'''
|
|
|
|
| 477 |
</div>
|
| 478 |
""", unsafe_allow_html=True)
|
| 479 |
|
| 480 |
+
# Display chat messages first
|
| 481 |
+
if st.session_state.help_conversation:
|
| 482 |
+
for msg in st.session_state.help_conversation:
|
| 483 |
+
# User message
|
| 484 |
+
st.markdown(f"""
|
| 485 |
+
<div class="chat-message user-message">
|
| 486 |
+
<div class="message-content">{msg['query']}</div>
|
| 487 |
+
<div class="message-timestamp">You</div>
|
| 488 |
+
</div>
|
| 489 |
+
""", unsafe_allow_html=True)
|
| 490 |
+
|
| 491 |
+
# Assistant message
|
| 492 |
+
st.markdown(f"""
|
| 493 |
+
<div class="chat-message assistant-message">
|
| 494 |
+
<div class="message-content" style="color:#1e293b;">{msg['response']}</div>
|
| 495 |
+
<div class="message-timestamp">Assistant</div>
|
| 496 |
+
</div>
|
| 497 |
+
""", unsafe_allow_html=True)
|
| 498 |
+
|
| 499 |
+
# Chat input form at bottom (separate form to ensure it works)
|
| 500 |
+
with st.form("help_chat_form", clear_on_submit=True):
|
| 501 |
+
help_query = st.text_input("Type your question here:",
|
| 502 |
+
key="help_query",
|
| 503 |
+
placeholder="How to play? What are the rules?",
|
| 504 |
+
label_visibility="collapsed")
|
| 505 |
+
submitted = st.form_submit_button("Send →")
|
| 506 |
|
| 507 |
+
if submitted and help_query:
|
| 508 |
+
with st.spinner("Assistant is thinking..."):
|
| 509 |
+
help_response = ask_help_agent(help_query)
|
| 510 |
+
st.session_state.help_conversation.append({
|
| 511 |
+
"query": help_query,
|
| 512 |
+
"response": help_response
|
| 513 |
+
})
|
| 514 |
+
st.experimental_rerun()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
# Guess confirmation screen using text input response
|
| 516 |
elif st.session_state.game_state == "confirm_guess":
|
| 517 |
st.markdown(f'''
|