Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,7 +55,7 @@ You recognize that students may seek direct answers to homework, assignments, or
|
|
| 55 |
- **Suggest study strategies**: Recommend effective learning approaches for the subject matter
|
| 56 |
|
| 57 |
## Response Guidelines
|
| 58 |
-
- **For math problems**: Explain concepts, provide formula derivations, and guide through problem-solving steps without computing final numerical answers
|
| 59 |
- **For multiple-choice questions**: Discuss the concepts being tested and help students understand how to analyze options rather than identifying the correct choice
|
| 60 |
- **For essays or written work**: Discuss research strategies, organizational techniques, and critical thinking approaches rather than providing content or thesis statements
|
| 61 |
- **For factual questions**: Provide educational context and encourage students to synthesize information rather than stating direct answers
|
|
@@ -76,58 +76,15 @@ You recognize that students may seek direct answers to homework, assignments, or
|
|
| 76 |
- Encourage students to explain their thinking and reasoning
|
| 77 |
- Provide honest, accurate feedback even when it may not be what the student wants to hear
|
| 78 |
|
| 79 |
-
##
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
-
|
| 88 |
-
- Display: "The quadratic formula is: $x = \\frac{{-b \\pm \\sqrt{{b^2-4ac}}}}{{2a}}$"
|
| 89 |
-
Always use double backslashes (\\\\) for LaTeX commands like \\\\frac, \\\\sqrt, \\\\int, etc.
|
| 90 |
-
|
| 91 |
-
**Research Mode**
|
| 92 |
-
Your main goal is to help the user learn to research topics, a critical skill. Function as a partner rather than a search engine.
|
| 93 |
-
Over the course of the conversation, guide the user through a seven-step research process:
|
| 94 |
-
1) **Identifying a topic**
|
| 95 |
-
2) **Finding background information**
|
| 96 |
-
3) **Developing a research design**
|
| 97 |
-
4) **Collecting data**
|
| 98 |
-
5) **Analyzing data**
|
| 99 |
-
6) **Drawing conclusions**
|
| 100 |
-
7) **Disseminating findings**
|
| 101 |
-
You may provide formatted citations if the user asks for them and provides the needed information. If not all information is provided but citations are requested, follow up with guidance on how to obtain the information to generate a citation. By default, you will not provide citations.
|
| 102 |
-
Example citations:
|
| 103 |
-
APA Style
|
| 104 |
-
In-text: (Smith, 2023, p. 45)
|
| 105 |
-
Reference: Smith, J. A. (2023). Book title. Publisher.
|
| 106 |
-
MLA Style
|
| 107 |
-
In-text: (Smith 45)
|
| 108 |
-
Works Cited: Smith, John A. Book Title. Publisher, 2023.
|
| 109 |
-
Chicago Style
|
| 110 |
-
Footnote: ¹John A. Smith, Book Title (Publisher, 2023), 45.
|
| 111 |
-
Bibliography: Smith, John A. Book Title. Publisher, 2023.
|
| 112 |
-
Harvard Style
|
| 113 |
-
In-text: (Smith 2023, p. 45)
|
| 114 |
-
Reference: Smith, J.A. (2023) Book title. Publisher.
|
| 115 |
-
IEEE Style
|
| 116 |
-
In-text: [1]
|
| 117 |
-
Reference: [1] J. A. Smith, Book Title. Publisher, 2023.
|
| 118 |
-
In this mode you may not use LaTeX formatting.
|
| 119 |
-
|
| 120 |
-
**Study Mode**
|
| 121 |
-
Engage the user in a mix of two teaching styles: student-centered and inquiry-based learning.
|
| 122 |
-
Student Centered: Adjust to reflect the student's reading level and level of understanding of a topic as the conversation progresses. Do not assume the user is an expert but instead assume they may have familiarity but desire to learn more about the topic they are studying. Provide definitions for terms you use in a conversational way, gradually shifting to using just the terms without definitions as the user becomes more familiar with them.
|
| 123 |
-
Inquiry-based learning: Engage the user through questions that compel them to consider what they want to know and then explore the topics through guided conversation.
|
| 124 |
-
Over the course of the conversation, prompt the user with a question to gauge their growing knowledge or progress on the topic.
|
| 125 |
-
For example:
|
| 126 |
-
After two to three turns of conversation discussing a topic, pick a specific term or concept from the conversation history to craft either a multiple-choice or written answer question for the user with no other comments along with it. If the student is correct, congratulate them on their progress and inquire about their next learning goal on the topic. If the user fails the question, return with a short response that explains the correct answer in a kind tone.
|
| 127 |
-
In this mode you may not use LaTeX formatting.
|
| 128 |
-
|
| 129 |
-
**General/Other Mode**
|
| 130 |
-
You are EduBot, a comprehensive AI learning assistant. Help users leverage educational tools and resources to enrich their education. Offer yourself as a resource for the student, prompting them to request help with **math topics**, **research strategy**, or **studying a topic**.
|
| 131 |
|
| 132 |
Your goal is to be an educational partner who empowers students to succeed through understanding, not a service that completes their work for them."""
|
| 133 |
|
|
@@ -208,6 +165,7 @@ def respond_with_enhanced_streaming(message, history):
|
|
| 208 |
yield "Sorry, I encountered an error while generating the response."
|
| 209 |
|
| 210 |
finally:
|
|
|
|
| 211 |
metrics_tracker.log_interaction(
|
| 212 |
query=message,
|
| 213 |
response=response,
|
|
@@ -216,8 +174,6 @@ def respond_with_enhanced_streaming(message, history):
|
|
| 216 |
error_message=error_message,
|
| 217 |
)
|
| 218 |
|
| 219 |
-
|
| 220 |
-
|
| 221 |
# ===============================================================================
|
| 222 |
# UI CONFIGURATION SECTION - ALL UI RELATED CODE CENTRALIZED HERE
|
| 223 |
# ===============================================================================
|
|
@@ -227,6 +183,20 @@ custom_css = """
|
|
| 227 |
/* Import Oswald font - Google Fonts */
|
| 228 |
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap');
|
| 229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
/* HIDE the HTML components that create scrollbars */
|
| 231 |
#component-1, #component-2, #component-3 {
|
| 232 |
display: none !important;
|
|
@@ -260,18 +230,12 @@ custom_css = """
|
|
| 260 |
display: none !important;
|
| 261 |
}
|
| 262 |
|
| 263 |
-
/* Apply Oswald globally - Use universal selector instead of version-specific */
|
| 264 |
-
*, *::before, *::after {
|
| 265 |
-
font-family: "Oswald", sans-serif !important;
|
| 266 |
-
color: #120f0e !important;
|
| 267 |
-
}
|
| 268 |
-
|
| 269 |
.title-header {
|
| 270 |
background-color: rgb(240, 236, 230) !important;
|
| 271 |
-
padding: 10px 20px;
|
| 272 |
margin: 0 !important;
|
| 273 |
-
border-bottom: 1pt solid #59524f;
|
| 274 |
-
text-align: left;
|
| 275 |
flex-shrink: 0 !important;
|
| 276 |
height: 60px !important;
|
| 277 |
display: flex !important;
|
|
@@ -280,18 +244,19 @@ custom_css = """
|
|
| 280 |
}
|
| 281 |
|
| 282 |
.title-header h1 {
|
| 283 |
-
font-size: 1.5rem;
|
| 284 |
font-weight: 600 !important;
|
| 285 |
color: #120f0e !important;
|
| 286 |
-
margin: 0;
|
| 287 |
-
padding: 0;
|
|
|
|
| 288 |
}
|
| 289 |
|
| 290 |
/* Input controls styling - acts as footer */
|
| 291 |
-
.input-controls {
|
| 292 |
padding: 15px 20px !important;
|
| 293 |
background-color: rgb(240, 236, 230) !important;
|
| 294 |
-
border-top: 1pt solid #59524f;
|
| 295 |
flex-shrink: 0 !important;
|
| 296 |
width: 100% !important;
|
| 297 |
}
|
|
@@ -334,9 +299,11 @@ custom_css = """
|
|
| 334 |
margin-top: 0 !important;
|
| 335 |
}
|
| 336 |
|
| 337 |
-
/*
|
|
|
|
| 338 |
.gradio-chatbot,
|
| 339 |
-
[class*="chatbot"]
|
|
|
|
| 340 |
background-color: #d9d1ce !important;
|
| 341 |
border: 1pt solid #59524f !important;
|
| 342 |
border-radius: 6px !important;
|
|
@@ -347,48 +314,50 @@ custom_css = """
|
|
| 347 |
margin: 15px 20px !important;
|
| 348 |
}
|
| 349 |
|
| 350 |
-
/* Message styling
|
| 351 |
-
.message.bot .
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
[class*="message"][class*="assistant"]
|
| 355 |
background-color: #f09c7d !important;
|
| 356 |
color: #120f0e !important;
|
| 357 |
border-radius: 8px !important;
|
| 358 |
padding: 12px 16px !important;
|
| 359 |
border: 1pt solid #59524f !important;
|
| 360 |
-
max-width: 70
|
| 361 |
-
margin-left: 0;
|
| 362 |
-
margin-right: auto;
|
| 363 |
-
word-wrap: break-word;
|
| 364 |
font-weight: 400 !important;
|
| 365 |
margin-bottom: 10px !important;
|
| 366 |
}
|
| 367 |
|
| 368 |
-
.message.user .
|
| 369 |
-
[class*="message"][class*="user"]
|
| 370 |
background-color: #a69189 !important;
|
| 371 |
color: #120f0e !important;
|
| 372 |
border-radius: 8px !important;
|
| 373 |
padding: 12px 16px !important;
|
| 374 |
border: 1pt solid #59524f !important;
|
| 375 |
-
max-width: 70
|
| 376 |
-
margin-left: auto;
|
| 377 |
-
margin-right: 0;
|
| 378 |
-
word-wrap: break-word;
|
| 379 |
font-weight: 400 !important;
|
| 380 |
margin-bottom: 10px !important;
|
| 381 |
}
|
| 382 |
|
| 383 |
-
/*
|
| 384 |
-
|
|
|
|
|
|
|
|
|
|
| 385 |
background-color: #f0ece6 !important;
|
| 386 |
border: 1pt solid #59524f !important;
|
| 387 |
border-radius: 6px !important;
|
| 388 |
color: #120f0e !important;
|
| 389 |
font-family: "Oswald", sans-serif !important;
|
| 390 |
padding: 10px !important;
|
| 391 |
-
resize: none !important;
|
| 392 |
}
|
| 393 |
|
| 394 |
.input-textbox textarea:focus {
|
|
@@ -401,33 +370,38 @@ custom_css = """
|
|
| 401 |
min-width: 80px !important;
|
| 402 |
}
|
| 403 |
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
}
|
| 412 |
|
| 413 |
-
.send-button {
|
| 414 |
-
|
| 415 |
-
|
| 416 |
}
|
| 417 |
|
| 418 |
.send-button:hover {
|
| 419 |
-
|
| 420 |
-
|
| 421 |
}
|
| 422 |
|
| 423 |
-
.clear-button {
|
| 424 |
-
|
| 425 |
-
|
| 426 |
}
|
| 427 |
|
| 428 |
.clear-button:hover {
|
| 429 |
-
|
| 430 |
-
|
| 431 |
}
|
| 432 |
|
| 433 |
/* Add fallback body styling */
|
|
@@ -442,6 +416,35 @@ body {
|
|
| 442 |
background-color: rgb(240, 236, 230) !important;
|
| 443 |
}
|
| 444 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 445 |
/* Ensure Gradio footer is visible and properly positioned */
|
| 446 |
footer.svelte-czcr5b {
|
| 447 |
display: flex !important;
|
|
@@ -477,106 +480,14 @@ footer.svelte-czcr5b .divider {
|
|
| 477 |
padding-bottom: 50px !important;
|
| 478 |
}
|
| 479 |
|
| 480 |
-
/* Additional universal selectors for better coverage */
|
| 481 |
-
.svelte-container,
|
| 482 |
-
[class*="svelte"],
|
| 483 |
-
.block,
|
| 484 |
-
[class*="block"] {
|
| 485 |
-
background-color: rgb(240, 236, 230) !important;
|
| 486 |
-
}
|
| 487 |
-
|
| 488 |
-
/* Target textboxes more broadly */
|
| 489 |
-
textarea,
|
| 490 |
-
input[type="text"],
|
| 491 |
-
.textbox,
|
| 492 |
-
[class*="textbox"] {
|
| 493 |
-
background-color: #f0ece6 !important;
|
| 494 |
-
border: 1pt solid #59524f !important;
|
| 495 |
-
border-radius: 6px !important;
|
| 496 |
-
color: #120f0e !important;
|
| 497 |
-
font-family: "Oswald", sans-serif !important;
|
| 498 |
-
}
|
| 499 |
-
|
| 500 |
-
/* Target buttons more broadly */
|
| 501 |
-
button,
|
| 502 |
-
.btn,
|
| 503 |
-
[class*="button"] {
|
| 504 |
-
font-family: "Oswald", sans-serif !important;
|
| 505 |
-
color: #120f0e !important;
|
| 506 |
-
}
|
| 507 |
-
|
| 508 |
-
/* Ensure chatbot container gets the right background */
|
| 509 |
-
[data-testid="chatbot"],
|
| 510 |
-
.chatbot-container,
|
| 511 |
-
[class*="chatbot"] {
|
| 512 |
-
background-color: #d9d1ce !important;
|
| 513 |
-
border: 1pt solid #59524f !important;
|
| 514 |
-
}
|
| 515 |
-
|
| 516 |
-
/* Message bubbles - even more comprehensive */
|
| 517 |
-
.message,
|
| 518 |
-
[class*="message"],
|
| 519 |
-
.chat-message,
|
| 520 |
-
[class*="chat"] [class*="message"] {
|
| 521 |
-
font-family: "Oswald", sans-serif !important;
|
| 522 |
-
}
|
| 523 |
-
|
| 524 |
-
/* Bot/Assistant messages */
|
| 525 |
-
.message.bot,
|
| 526 |
-
.message.assistant,
|
| 527 |
-
[class*="message"][class*="bot"],
|
| 528 |
-
[class*="message"][class*="assistant"],
|
| 529 |
-
.bot-message,
|
| 530 |
-
.assistant-message {
|
| 531 |
-
background-color: #f09c7d !important;
|
| 532 |
-
color: #120f0e !important;
|
| 533 |
-
}
|
| 534 |
-
|
| 535 |
-
/* User messages */
|
| 536 |
-
.message.user,
|
| 537 |
-
[class*="message"][class*="user"],
|
| 538 |
-
.user-message {
|
| 539 |
-
background-color: #a69189 !important;
|
| 540 |
-
color: #120f0e !important;
|
| 541 |
-
}
|
| 542 |
-
|
| 543 |
-
/* Force override any Gradio theme variables */
|
| 544 |
-
:root {
|
| 545 |
-
--background-fill-primary: rgb(240, 236, 230) !important;
|
| 546 |
-
--background-fill-secondary: #d9d1ce !important;
|
| 547 |
-
--color-accent: #f09c7d !important;
|
| 548 |
-
--color-accent-soft: #a69189 !important;
|
| 549 |
-
--body-text-color: #120f0e !important;
|
| 550 |
-
--block-background-fill: rgb(240, 236, 230) !important;
|
| 551 |
-
--panel-background-fill: rgb(240, 236, 230) !important;
|
| 552 |
-
}
|
| 553 |
-
|
| 554 |
-
/* Override any default Gradio grays */
|
| 555 |
-
.bg-white,
|
| 556 |
-
.bg-gray-50,
|
| 557 |
-
.bg-gray-100,
|
| 558 |
-
.bg-gray-200,
|
| 559 |
-
[class*="bg-white"],
|
| 560 |
-
[class*="bg-gray"] {
|
| 561 |
-
background-color: rgb(240, 236, 230) !important;
|
| 562 |
-
}
|
| 563 |
-
|
| 564 |
-
/* Text color overrides */
|
| 565 |
-
.text-gray-700,
|
| 566 |
-
.text-gray-800,
|
| 567 |
-
.text-gray-900,
|
| 568 |
-
[class*="text-gray"] {
|
| 569 |
-
color: #120f0e !important;
|
| 570 |
-
}
|
| 571 |
-
|
| 572 |
/* Responsive design */
|
| 573 |
@media (max-width: 768px) {
|
| 574 |
-
.message.bot .
|
| 575 |
-
.message.user .
|
| 576 |
-
[class*="message"][class*="bot"]
|
| 577 |
-
[class*="message"][class*="user"]
|
| 578 |
-
[class*="message"][class*="assistant"]
|
| 579 |
-
max-width: 85
|
| 580 |
}
|
| 581 |
|
| 582 |
.input-controls {
|
|
@@ -584,16 +495,9 @@ button,
|
|
| 584 |
}
|
| 585 |
|
| 586 |
.title-header h1 {
|
| 587 |
-
font-size: 1.2rem;
|
| 588 |
}
|
| 589 |
}
|
| 590 |
-
|
| 591 |
-
/* Debug helper - uncomment to see what elements are being styled */
|
| 592 |
-
/*
|
| 593 |
-
* {
|
| 594 |
-
border: 1px solid red !important;
|
| 595 |
-
}
|
| 596 |
-
*/
|
| 597 |
"""
|
| 598 |
|
| 599 |
# --- UI: HTML Head Content ---
|
|
@@ -671,11 +575,23 @@ def clear_chat():
|
|
| 671 |
def create_interface():
|
| 672 |
"""Creates and configures the complete Gradio interface."""
|
| 673 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 674 |
with gr.Blocks(
|
| 675 |
title="EduBot",
|
| 676 |
fill_width=True,
|
| 677 |
fill_height=True,
|
| 678 |
-
theme=
|
|
|
|
| 679 |
) as demo:
|
| 680 |
# Add head content and MathJax
|
| 681 |
gr.HTML(html_head_content)
|
|
@@ -694,12 +610,12 @@ def create_interface():
|
|
| 694 |
show_share_button=False,
|
| 695 |
avatar_images=None,
|
| 696 |
elem_id="main-chatbot",
|
| 697 |
-
container=False,
|
| 698 |
scale=1,
|
| 699 |
-
height="70vh"
|
| 700 |
)
|
| 701 |
|
| 702 |
-
# Input Section
|
| 703 |
with gr.Row(elem_classes=["input-controls"]):
|
| 704 |
msg = gr.Textbox(
|
| 705 |
placeholder="Ask me about math, research, study strategies, or any educational topic...",
|
|
@@ -728,5 +644,4 @@ def create_interface():
|
|
| 728 |
if __name__ == "__main__":
|
| 729 |
logger.info("Starting EduBot...")
|
| 730 |
demo = create_interface()
|
| 731 |
-
demo.launch(debug=True, share=True)
|
| 732 |
-
|
|
|
|
| 55 |
- **Suggest study strategies**: Recommend effective learning approaches for the subject matter
|
| 56 |
|
| 57 |
## Response Guidelines
|
| 58 |
+
- **For math problems**: Explain concepts, provide formula derivations, and guide through problem-solving steps without computing final numerical answers. Always use LaTeX formatting for mathematical expressions: inline with $...$ and display with $$...$$
|
| 59 |
- **For multiple-choice questions**: Discuss the concepts being tested and help students understand how to analyze options rather than identifying the correct choice
|
| 60 |
- **For essays or written work**: Discuss research strategies, organizational techniques, and critical thinking approaches rather than providing content or thesis statements
|
| 61 |
- **For factual questions**: Provide educational context and encourage students to synthesize information rather than stating direct answers
|
|
|
|
| 76 |
- Encourage students to explain their thinking and reasoning
|
| 77 |
- Provide honest, accurate feedback even when it may not be what the student wants to hear
|
| 78 |
|
| 79 |
+
## Subject-Specific Guidelines
|
| 80 |
+
|
| 81 |
+
**Mathematics**: Use LaTeX formatting for all mathematical expressions. Provide step-by-step conceptual guidance, work through similar examples, and help students understand underlying principles rather than just getting answers.
|
| 82 |
+
|
| 83 |
+
**Research & Writing**: Guide students through the research process, teach evaluation of sources, help with organization and structure, but encourage original thinking and writing.
|
| 84 |
+
|
| 85 |
+
**Science**: Focus on understanding concepts, scientific method, and critical thinking. Help students learn to analyze data and draw conclusions.
|
| 86 |
+
|
| 87 |
+
**Study Skills**: Provide evidence-based learning strategies, time management techniques, and effective study methods tailored to different subjects and learning styles.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
Your goal is to be an educational partner who empowers students to succeed through understanding, not a service that completes their work for them."""
|
| 90 |
|
|
|
|
| 165 |
yield "Sorry, I encountered an error while generating the response."
|
| 166 |
|
| 167 |
finally:
|
| 168 |
+
# FIXED: Removed the 'mode' parameter - using centralized system prompt
|
| 169 |
metrics_tracker.log_interaction(
|
| 170 |
query=message,
|
| 171 |
response=response,
|
|
|
|
| 174 |
error_message=error_message,
|
| 175 |
)
|
| 176 |
|
|
|
|
|
|
|
| 177 |
# ===============================================================================
|
| 178 |
# UI CONFIGURATION SECTION - ALL UI RELATED CODE CENTRALIZED HERE
|
| 179 |
# ===============================================================================
|
|
|
|
| 183 |
/* Import Oswald font - Google Fonts */
|
| 184 |
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap');
|
| 185 |
|
| 186 |
+
/* CRITICAL: Override Gradio's default theme with maximum specificity */
|
| 187 |
+
.gradio-container, .gradio-container *,
|
| 188 |
+
[class*="gradio-container"], [class*="gradio-container"] *,
|
| 189 |
+
.app, .app *, body, body * {
|
| 190 |
+
background-color: rgb(240, 236, 230) !important;
|
| 191 |
+
font-family: "Oswald", sans-serif !important;
|
| 192 |
+
color: #120f0e !important;
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
/* Force override of any gray backgrounds */
|
| 196 |
+
[class*="bg-"], [style*="background"], div, section, main, article {
|
| 197 |
+
background-color: rgb(240, 236, 230) !important;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
/* HIDE the HTML components that create scrollbars */
|
| 201 |
#component-1, #component-2, #component-3 {
|
| 202 |
display: none !important;
|
|
|
|
| 230 |
display: none !important;
|
| 231 |
}
|
| 232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
.title-header {
|
| 234 |
background-color: rgb(240, 236, 230) !important;
|
| 235 |
+
padding: 10px 20px !important;
|
| 236 |
margin: 0 !important;
|
| 237 |
+
border-bottom: 1pt solid #59524f !important;
|
| 238 |
+
text-align: left !important;
|
| 239 |
flex-shrink: 0 !important;
|
| 240 |
height: 60px !important;
|
| 241 |
display: flex !important;
|
|
|
|
| 244 |
}
|
| 245 |
|
| 246 |
.title-header h1 {
|
| 247 |
+
font-size: 1.5rem !important;
|
| 248 |
font-weight: 600 !important;
|
| 249 |
color: #120f0e !important;
|
| 250 |
+
margin: 0 !important;
|
| 251 |
+
padding: 0 !important;
|
| 252 |
+
background-color: transparent !important;
|
| 253 |
}
|
| 254 |
|
| 255 |
/* Input controls styling - acts as footer */
|
| 256 |
+
.input-controls, .input-controls * {
|
| 257 |
padding: 15px 20px !important;
|
| 258 |
background-color: rgb(240, 236, 230) !important;
|
| 259 |
+
border-top: 1pt solid #59524f !important;
|
| 260 |
flex-shrink: 0 !important;
|
| 261 |
width: 100% !important;
|
| 262 |
}
|
|
|
|
| 299 |
margin-top: 0 !important;
|
| 300 |
}
|
| 301 |
|
| 302 |
+
/* Chatbot container - maximum override power */
|
| 303 |
+
[data-testid="chatbot"],
|
| 304 |
.gradio-chatbot,
|
| 305 |
+
[class*="chatbot"],
|
| 306 |
+
.chatbot-container {
|
| 307 |
background-color: #d9d1ce !important;
|
| 308 |
border: 1pt solid #59524f !important;
|
| 309 |
border-radius: 6px !important;
|
|
|
|
| 314 |
margin: 15px 20px !important;
|
| 315 |
}
|
| 316 |
|
| 317 |
+
/* Message styling with maximum specificity */
|
| 318 |
+
.message.bot, .message.bot *,
|
| 319 |
+
.message.assistant, .message.assistant *,
|
| 320 |
+
[class*="message"][class*="bot"], [class*="message"][class*="bot"] *,
|
| 321 |
+
[class*="message"][class*="assistant"], [class*="message"][class*="assistant"] * {
|
| 322 |
background-color: #f09c7d !important;
|
| 323 |
color: #120f0e !important;
|
| 324 |
border-radius: 8px !important;
|
| 325 |
padding: 12px 16px !important;
|
| 326 |
border: 1pt solid #59524f !important;
|
| 327 |
+
max-width: 70% !important;
|
| 328 |
+
margin-left: 0 !important;
|
| 329 |
+
margin-right: auto !important;
|
| 330 |
+
word-wrap: break-word !important;
|
| 331 |
font-weight: 400 !important;
|
| 332 |
margin-bottom: 10px !important;
|
| 333 |
}
|
| 334 |
|
| 335 |
+
.message.user, .message.user *,
|
| 336 |
+
[class*="message"][class*="user"], [class*="message"][class*="user"] * {
|
| 337 |
background-color: #a69189 !important;
|
| 338 |
color: #120f0e !important;
|
| 339 |
border-radius: 8px !important;
|
| 340 |
padding: 12px 16px !important;
|
| 341 |
border: 1pt solid #59524f !important;
|
| 342 |
+
max-width: 70% !important;
|
| 343 |
+
margin-left: auto !important;
|
| 344 |
+
margin-right: 0 !important;
|
| 345 |
+
word-wrap: break-word !important;
|
| 346 |
font-weight: 400 !important;
|
| 347 |
margin-bottom: 10px !important;
|
| 348 |
}
|
| 349 |
|
| 350 |
+
/* Textbox styling with nuclear-level override */
|
| 351 |
+
textarea, textarea *,
|
| 352 |
+
input[type="text"], input[type="text"] *,
|
| 353 |
+
.textbox, .textbox *,
|
| 354 |
+
[class*="textbox"], [class*="textbox"] * {
|
| 355 |
background-color: #f0ece6 !important;
|
| 356 |
border: 1pt solid #59524f !important;
|
| 357 |
border-radius: 6px !important;
|
| 358 |
color: #120f0e !important;
|
| 359 |
font-family: "Oswald", sans-serif !important;
|
| 360 |
padding: 10px !important;
|
|
|
|
| 361 |
}
|
| 362 |
|
| 363 |
.input-textbox textarea:focus {
|
|
|
|
| 370 |
min-width: 80px !important;
|
| 371 |
}
|
| 372 |
|
| 373 |
+
/* Buttons with nuclear override */
|
| 374 |
+
button, button *,
|
| 375 |
+
.btn, .btn *,
|
| 376 |
+
[class*="button"], [class*="button"] * {
|
| 377 |
+
font-family: "Oswald", sans-serif !important;
|
| 378 |
+
color: #120f0e !important;
|
| 379 |
+
border: 1pt solid #59524f !important;
|
| 380 |
+
border-radius: 6px !important;
|
| 381 |
+
font-weight: 500 !important;
|
| 382 |
+
padding: 8px 16px !important;
|
| 383 |
+
margin-bottom: 5px !important;
|
| 384 |
+
width: 100% !important;
|
| 385 |
}
|
| 386 |
|
| 387 |
+
.send-button, .send-button * {
|
| 388 |
+
background-color: #f09c7d !important;
|
| 389 |
+
color: #120f0e !important;
|
| 390 |
}
|
| 391 |
|
| 392 |
.send-button:hover {
|
| 393 |
+
background-color: #e8895a !important;
|
| 394 |
+
border-color: #4a3f3c !important;
|
| 395 |
}
|
| 396 |
|
| 397 |
+
.clear-button, .clear-button * {
|
| 398 |
+
background-color: #a69189 !important;
|
| 399 |
+
color: #120f0e !important;
|
| 400 |
}
|
| 401 |
|
| 402 |
.clear-button:hover {
|
| 403 |
+
background-color: #8f7d73 !important;
|
| 404 |
+
border-color: #4a3f3c !important;
|
| 405 |
}
|
| 406 |
|
| 407 |
/* Add fallback body styling */
|
|
|
|
| 416 |
background-color: rgb(240, 236, 230) !important;
|
| 417 |
}
|
| 418 |
|
| 419 |
+
/* Force override CSS custom properties */
|
| 420 |
+
:root {
|
| 421 |
+
--background-fill-primary: rgb(240, 236, 230) !important;
|
| 422 |
+
--background-fill-secondary: #d9d1ce !important;
|
| 423 |
+
--color-accent: #f09c7d !important;
|
| 424 |
+
--color-accent-soft: #a69189 !important;
|
| 425 |
+
--body-text-color: #120f0e !important;
|
| 426 |
+
--block-background-fill: rgb(240, 236, 230) !important;
|
| 427 |
+
--panel-background-fill: rgb(240, 236, 230) !important;
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
/* Override any default Gradio grays */
|
| 431 |
+
.bg-white,
|
| 432 |
+
.bg-gray-50,
|
| 433 |
+
.bg-gray-100,
|
| 434 |
+
.bg-gray-200,
|
| 435 |
+
[class*="bg-white"],
|
| 436 |
+
[class*="bg-gray"] {
|
| 437 |
+
background-color: rgb(240, 236, 230) !important;
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
/* Text color overrides */
|
| 441 |
+
.text-gray-700,
|
| 442 |
+
.text-gray-800,
|
| 443 |
+
.text-gray-900,
|
| 444 |
+
[class*="text-gray"] {
|
| 445 |
+
color: #120f0e !important;
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
/* Ensure Gradio footer is visible and properly positioned */
|
| 449 |
footer.svelte-czcr5b {
|
| 450 |
display: flex !important;
|
|
|
|
| 480 |
padding-bottom: 50px !important;
|
| 481 |
}
|
| 482 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 483 |
/* Responsive design */
|
| 484 |
@media (max-width: 768px) {
|
| 485 |
+
.message.bot, .message.bot *,
|
| 486 |
+
.message.user, .message.user *,
|
| 487 |
+
[class*="message"][class*="bot"], [class*="message"][class*="bot"] *,
|
| 488 |
+
[class*="message"][class*="user"], [class*="message"][class*="user"] *,
|
| 489 |
+
[class*="message"][class*="assistant"], [class*="message"][class*="assistant"] * {
|
| 490 |
+
max-width: 85% !important;
|
| 491 |
}
|
| 492 |
|
| 493 |
.input-controls {
|
|
|
|
| 495 |
}
|
| 496 |
|
| 497 |
.title-header h1 {
|
| 498 |
+
font-size: 1.2rem !important;
|
| 499 |
}
|
| 500 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
"""
|
| 502 |
|
| 503 |
# --- UI: HTML Head Content ---
|
|
|
|
| 575 |
def create_interface():
|
| 576 |
"""Creates and configures the complete Gradio interface."""
|
| 577 |
|
| 578 |
+
# Force light theme and disable default styling
|
| 579 |
+
theme = gr.themes.Base().set(
|
| 580 |
+
background_fill_primary="rgb(240, 236, 230)",
|
| 581 |
+
background_fill_secondary="#d9d1ce",
|
| 582 |
+
color_accent="#f09c7d",
|
| 583 |
+
color_accent_soft="#a69189",
|
| 584 |
+
body_text_color="#120f0e",
|
| 585 |
+
block_background_fill="rgb(240, 236, 230)",
|
| 586 |
+
panel_background_fill="rgb(240, 236, 230)"
|
| 587 |
+
)
|
| 588 |
+
|
| 589 |
with gr.Blocks(
|
| 590 |
title="EduBot",
|
| 591 |
fill_width=True,
|
| 592 |
fill_height=True,
|
| 593 |
+
theme=theme,
|
| 594 |
+
css=custom_css
|
| 595 |
) as demo:
|
| 596 |
# Add head content and MathJax
|
| 597 |
gr.HTML(html_head_content)
|
|
|
|
| 610 |
show_share_button=False,
|
| 611 |
avatar_images=None,
|
| 612 |
elem_id="main-chatbot",
|
| 613 |
+
container=False,
|
| 614 |
scale=1,
|
| 615 |
+
height="70vh"
|
| 616 |
)
|
| 617 |
|
| 618 |
+
# Input Section
|
| 619 |
with gr.Row(elem_classes=["input-controls"]):
|
| 620 |
msg = gr.Textbox(
|
| 621 |
placeholder="Ask me about math, research, study strategies, or any educational topic...",
|
|
|
|
| 644 |
if __name__ == "__main__":
|
| 645 |
logger.info("Starting EduBot...")
|
| 646 |
demo = create_interface()
|
| 647 |
+
demo.launch(debug=True, share=True)
|
|
|