Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,7 +27,7 @@ metrics_tracker = EduBotMetrics(save_file="edu_metrics.json")
|
|
| 27 |
|
| 28 |
# --- LLM Templates ---
|
| 29 |
# Enhanced base system message
|
| 30 |
-
|
| 31 |
|
| 32 |
## Core Educational Principles
|
| 33 |
- Provide comprehensive, educational responses that help students truly understand concepts
|
|
@@ -158,7 +158,7 @@ def respond_with_enhanced_streaming(message, history):
|
|
| 158 |
|
| 159 |
try:
|
| 160 |
# Build conversation history (last 5 exchanges)
|
| 161 |
-
api_messages = [{"role": "system", "content":
|
| 162 |
if history:
|
| 163 |
for exchange in history[-5:]:
|
| 164 |
if exchange.get("role") == "user":
|
|
@@ -286,16 +286,15 @@ custom_css = """
|
|
| 286 |
padding: 0;
|
| 287 |
}
|
| 288 |
|
| 289 |
-
/* Chat styling -
|
| 290 |
.gradio-container-5-42-0 .gradio-chatbot {
|
| 291 |
background-color: #d9d1ce !important;
|
| 292 |
border: 1pt solid #59524f !important;
|
| 293 |
border-radius: 6px !important;
|
| 294 |
padding: 15px !important;
|
| 295 |
-
|
| 296 |
-
|
| 297 |
overflow-y: auto !important;
|
| 298 |
-
flex: 1 !important;
|
| 299 |
margin: 15px 20px !important;
|
| 300 |
}
|
| 301 |
|
|
@@ -314,102 +313,8 @@ custom_css = """
|
|
| 314 |
margin-bottom: 10px !important;
|
| 315 |
}
|
| 316 |
|
| 317 |
-
.gradio-container-5-
|
| 318 |
-
background-color: #ada3a0 !important;
|
| 319 |
-
color: #120f0e !important;
|
| 320 |
-
border-radius: 8px !important;
|
| 321 |
-
padding: 12px 16px !important;
|
| 322 |
-
border: 1pt solid #59524f !important;
|
| 323 |
-
max-width: 70%;
|
| 324 |
-
margin-left: auto;
|
| 325 |
-
margin-right: 0;
|
| 326 |
-
word-wrap: break-word;
|
| 327 |
-
font-weight: 400 !important;
|
| 328 |
-
margin-bottom: 10px !important;
|
| 329 |
-
}
|
| 330 |
-
|
| 331 |
-
/* Input controls layout */
|
| 332 |
-
.input-controls {
|
| 333 |
-
display: flex !important;
|
| 334 |
-
gap: 15px !important;
|
| 335 |
-
align-items: stretch !important;
|
| 336 |
-
height: 60px !important;
|
| 337 |
-
padding: 15px 20px !important;
|
| 338 |
-
background-color: rgb(240, 236, 230) !important;
|
| 339 |
-
border-top: 1pt solid #59524f !important;
|
| 340 |
-
flex-shrink: 0 !important;
|
| 341 |
-
}
|
| 342 |
|
| 343 |
-
/* Button styling - compact */
|
| 344 |
-
.button-column {
|
| 345 |
-
display: flex !important;
|
| 346 |
-
flex-direction: column !important;
|
| 347 |
-
gap: 5px !important;
|
| 348 |
-
min-width: 80px !important;
|
| 349 |
-
}
|
| 350 |
-
|
| 351 |
-
.gradio-container-5-42-0 .send-button,
|
| 352 |
-
.gradio-container-5-42-0 .clear-button {
|
| 353 |
-
color: #120f0e !important;
|
| 354 |
-
border: 1pt solid #59524f !important;
|
| 355 |
-
border-radius: 6px !important;
|
| 356 |
-
padding: 6px 12px !important;
|
| 357 |
-
cursor: pointer !important;
|
| 358 |
-
margin: 0 !important;
|
| 359 |
-
font-weight: 500 !important;
|
| 360 |
-
height: 22px !important;
|
| 361 |
-
font-size: 11px !important;
|
| 362 |
-
}
|
| 363 |
-
|
| 364 |
-
.gradio-container-5-42-0 .send-button {
|
| 365 |
-
background-color: #f09c7d !important;
|
| 366 |
-
}
|
| 367 |
-
|
| 368 |
-
.gradio-container-5-42-0 .clear-button {
|
| 369 |
-
background-color: #ada3a0 !important;
|
| 370 |
-
}
|
| 371 |
-
|
| 372 |
-
/* Textbox styling - single line */
|
| 373 |
-
.gradio-container-5-42-0 .input-textbox {
|
| 374 |
-
background-color: #d9d1ce !important;
|
| 375 |
-
border: 1pt solid #59524f !important;
|
| 376 |
-
border-radius: 8px !important;
|
| 377 |
-
flex: 1 !important;
|
| 378 |
-
height: 50px !important;
|
| 379 |
-
}
|
| 380 |
-
|
| 381 |
-
.gradio-container-5-42-0 .input-textbox textarea {
|
| 382 |
-
background-color: #d9d1ce !important;
|
| 383 |
-
border: none !important;
|
| 384 |
-
color: #120f0e !important;
|
| 385 |
-
padding: 12px !important;
|
| 386 |
-
font-size: 14px !important;
|
| 387 |
-
font-weight: 400 !important;
|
| 388 |
-
resize: none !important;
|
| 389 |
-
height: 50px !important;
|
| 390 |
-
min-height: 50px !important;
|
| 391 |
-
max-height: 50px !important;
|
| 392 |
-
line-height: 1.2 !important;
|
| 393 |
-
}
|
| 394 |
-
|
| 395 |
-
.gradio-container-5-42-0 .input-textbox textarea::placeholder {
|
| 396 |
-
font-weight: 300 !important;
|
| 397 |
-
color: rgba(18, 15, 14, 0.6) !important;
|
| 398 |
-
}
|
| 399 |
-
|
| 400 |
-
/* Hide any scrollbars that might appear incorrectly */
|
| 401 |
-
body {
|
| 402 |
-
overflow: hidden !important;
|
| 403 |
-
margin: 0 !important;
|
| 404 |
-
padding: 0 !important;
|
| 405 |
-
}
|
| 406 |
-
|
| 407 |
-
html {
|
| 408 |
-
overflow: hidden !important;
|
| 409 |
-
margin: 0 !important;
|
| 410 |
-
padding: 0 !important;
|
| 411 |
-
}
|
| 412 |
-
"""
|
| 413 |
|
| 414 |
# --- UI: HTML Head Content ---
|
| 415 |
html_head_content = '''
|
|
|
|
| 27 |
|
| 28 |
# --- LLM Templates ---
|
| 29 |
# Enhanced base system message
|
| 30 |
+
SYSTEM_MESSAGE = """You are EduBot, an expert multi-concept tutor designed to facilitate genuine learning and understanding. Your primary mission is to guide students through the learning process rather than providing direct answers to academic work.
|
| 31 |
|
| 32 |
## Core Educational Principles
|
| 33 |
- Provide comprehensive, educational responses that help students truly understand concepts
|
|
|
|
| 158 |
|
| 159 |
try:
|
| 160 |
# Build conversation history (last 5 exchanges)
|
| 161 |
+
api_messages = [{"role": "system", "content": SYSTEM_MESSAGE}]
|
| 162 |
if history:
|
| 163 |
for exchange in history[-5:]:
|
| 164 |
if exchange.get("role") == "user":
|
|
|
|
| 286 |
padding: 0;
|
| 287 |
}
|
| 288 |
|
| 289 |
+
/* Chat styling - FLEX to fill space */
|
| 290 |
.gradio-container-5-42-0 .gradio-chatbot {
|
| 291 |
background-color: #d9d1ce !important;
|
| 292 |
border: 1pt solid #59524f !important;
|
| 293 |
border-radius: 6px !important;
|
| 294 |
padding: 15px !important;
|
| 295 |
+
flex: 1 !important; /* Fill all remaining space */
|
| 296 |
+
min-height: 0 !important; /* Prevent overflow issues */
|
| 297 |
overflow-y: auto !important;
|
|
|
|
| 298 |
margin: 15px 20px !important;
|
| 299 |
}
|
| 300 |
|
|
|
|
| 313 |
margin-bottom: 10px !important;
|
| 314 |
}
|
| 315 |
|
| 316 |
+
.gradio-container-5-4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
|
| 319 |
# --- UI: HTML Head Content ---
|
| 320 |
html_head_content = '''
|