iisadia commited on
Commit
061722d
·
verified ·
1 Parent(s): 305f0f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -33
app.py CHANGED
@@ -477,40 +477,41 @@ def main():
477
  </div>
478
  """, unsafe_allow_html=True)
479
 
480
- # Chat messages container
481
- chat_container = st.container()
482
-
483
- # Input at bottom
484
- with st.form("help_chat_form"):
485
- cols = st.columns([4, 1])
486
- help_query = cols[0].text_input("Type your question here:", key="help_query",
487
- placeholder="How to play? What are the rules?")
488
- submitted = cols[1].form_submit_button("Send →")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489
 
490
- if submitted and help_query:
491
- help_response = ask_help_agent(help_query)
492
- st.session_state.help_conversation.append({"query": help_query, "response": help_response})
493
- st.experimental_rerun()
494
-
495
- # Display chat messages
496
- with chat_container:
497
- if st.session_state.help_conversation:
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'''