Update app.py
Browse files
app.py
CHANGED
|
@@ -54,7 +54,6 @@ def inject_custom_css():
|
|
| 54 |
border: 1px solid #e2e8f0;
|
| 55 |
position: relative;
|
| 56 |
transition: transform 0.2s ease;
|
| 57 |
-
color: #1E293B; /* Add this line to ensure black text */
|
| 58 |
}
|
| 59 |
|
| 60 |
.question-box:hover {
|
|
@@ -120,77 +119,12 @@ def inject_custom_css():
|
|
| 120 |
}
|
| 121 |
|
| 122 |
.help-chat {
|
| 123 |
-
background: rgba(255,255,255,0.
|
| 124 |
-
backdrop-filter: blur(
|
| 125 |
-
border-radius:
|
| 126 |
-
padding: 1.5rem;
|
| 127 |
-
margin: 2rem 0;
|
| 128 |
-
box-shadow: 0 12px 40px rgba(0,0,0,0.15);
|
| 129 |
-
border: 1px solid #e2e8f0;
|
| 130 |
-
max-height: 400px;
|
| 131 |
-
overflow-y: auto;
|
| 132 |
-
}
|
| 133 |
-
.chat-header {
|
| 134 |
-
display: flex;
|
| 135 |
-
align-items: center;
|
| 136 |
-
gap: 12px;
|
| 137 |
-
margin-bottom: 1.5rem;
|
| 138 |
-
padding-bottom: 1rem;
|
| 139 |
-
border-bottom: 2px solid #f1f5f9;
|
| 140 |
-
}
|
| 141 |
-
|
| 142 |
-
.chat-header-icon {
|
| 143 |
-
background: #6C63FF;
|
| 144 |
-
width: 40px;
|
| 145 |
-
height: 40px;
|
| 146 |
-
border-radius: 12px;
|
| 147 |
-
display: flex;
|
| 148 |
-
align-items: center;
|
| 149 |
-
justify-content: center;
|
| 150 |
-
color: white;
|
| 151 |
-
font-size: 1.2rem;
|
| 152 |
-
}
|
| 153 |
-
|
| 154 |
-
.chat-message {
|
| 155 |
-
margin: 1rem 0;
|
| 156 |
padding: 1rem;
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
animation: fadeInSlide 0.3s ease;
|
| 160 |
-
}
|
| 161 |
-
|
| 162 |
-
.user-message {
|
| 163 |
-
background: #6C63FF;
|
| 164 |
-
color: white;
|
| 165 |
-
margin-left: auto;
|
| 166 |
-
border-bottom-right-radius: 4px;
|
| 167 |
-
}
|
| 168 |
-
|
| 169 |
-
.assistant-message {
|
| 170 |
-
background: #f8f9fa;
|
| 171 |
-
color: #1e293b;
|
| 172 |
-
margin-right: auto;
|
| 173 |
-
border-bottom-left-radius: 4px;
|
| 174 |
-
}
|
| 175 |
-
|
| 176 |
-
.message-content {
|
| 177 |
-
font-size: 0.95rem;
|
| 178 |
-
line-height: 1.5;
|
| 179 |
-
}
|
| 180 |
-
|
| 181 |
-
.message-timestamp {
|
| 182 |
-
font-size: 0.75rem;
|
| 183 |
-
color: #64748b;
|
| 184 |
-
margin-top: 0.5rem;
|
| 185 |
-
text-align: right;
|
| 186 |
-
}
|
| 187 |
-
|
| 188 |
-
.chat-input {
|
| 189 |
-
position: sticky;
|
| 190 |
-
bottom: 0;
|
| 191 |
-
background: white;
|
| 192 |
-
padding-top: 1rem;
|
| 193 |
-
margin-top: 1rem;
|
| 194 |
}
|
| 195 |
|
| 196 |
@keyframes fadeInSlide {
|
|
@@ -467,51 +401,19 @@ def main():
|
|
| 467 |
st.experimental_rerun()
|
| 468 |
|
| 469 |
# Side Help Option: independent chat with an AI help assistant using Hugging Face model
|
| 470 |
-
with st.expander("
|
| 471 |
-
st.
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 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 |
-
|
| 484 |
-
st.markdown(f""
|
| 485 |
-
|
| 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'''
|
|
|
|
| 54 |
border: 1px solid #e2e8f0;
|
| 55 |
position: relative;
|
| 56 |
transition: transform 0.2s ease;
|
|
|
|
| 57 |
}
|
| 58 |
|
| 59 |
.question-box:hover {
|
|
|
|
| 119 |
}
|
| 120 |
|
| 121 |
.help-chat {
|
| 122 |
+
background: rgba(255,255,255,0.9);
|
| 123 |
+
backdrop-filter: blur(10px);
|
| 124 |
+
border-radius: 15px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
padding: 1rem;
|
| 126 |
+
margin: 1rem 0;
|
| 127 |
+
box-shadow: 0 8px 30px rgba(0,0,0,0.12);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
}
|
| 129 |
|
| 130 |
@keyframes fadeInSlide {
|
|
|
|
| 401 |
st.experimental_rerun()
|
| 402 |
|
| 403 |
# Side Help Option: independent chat with an AI help assistant using Hugging Face model
|
| 404 |
+
with st.expander("Need Help? Chat with AI Assistant"):
|
| 405 |
+
help_query = st.text_input("Enter your help query:", key="help_query")
|
| 406 |
+
if st.button("Send", key="send_help"):
|
| 407 |
+
if help_query:
|
| 408 |
+
help_response = ask_help_agent(help_query)
|
| 409 |
+
st.session_state.help_conversation.append({"query": help_query, "response": help_response})
|
| 410 |
+
else:
|
| 411 |
+
st.error("Please enter a query!")
|
|
|
|
|
|
|
|
|
|
| 412 |
if st.session_state.help_conversation:
|
| 413 |
for msg in st.session_state.help_conversation:
|
| 414 |
+
st.markdown(f"**You:** {msg['query']}")
|
| 415 |
+
st.markdown(f"**Help Assistant:** {msg['response']}")
|
| 416 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 417 |
# Guess confirmation screen using text input response
|
| 418 |
elif st.session_state.game_state == "confirm_guess":
|
| 419 |
st.markdown(f'''
|