Spaces:
Sleeping
Sleeping
app.py
#1
by maryamshanabli - opened
app.py
CHANGED
|
@@ -1,398 +1,648 @@
|
|
| 1 |
-
# app.py β Clean, fixed, single-file Gradio app for Synchrony
|
| 2 |
-
# Last updated: 2025-11-06
|
| 3 |
-
# Author: (rewritten for Lujain)
|
| 4 |
-
# -------------------------------------------------------
|
| 5 |
-
|
| 6 |
import gradio as gr
|
| 7 |
import requests
|
|
|
|
| 8 |
from datetime import datetime
|
| 9 |
-
from typing import Tuple, Any, Dict, List
|
| 10 |
|
| 11 |
# ============================================
|
| 12 |
-
#
|
| 13 |
# ============================================
|
|
|
|
|
|
|
| 14 |
BASE_URL = "https://maryyam.app.n8n.cloud/webhook-test"
|
| 15 |
START_SESSION_URL = f"{BASE_URL}/start-session"
|
| 16 |
GENERATE_CHALLENGES_URL = f"{BASE_URL}/generate-challenges"
|
| 17 |
REQUEST_HINT_URL = f"{BASE_URL}/request-hint"
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
|
|
|
|
|
|
| 22 |
|
| 23 |
# ============================================
|
| 24 |
-
#
|
| 25 |
# ============================================
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
try:
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
else:
|
| 35 |
-
return
|
|
|
|
| 36 |
except Exception as e:
|
| 37 |
-
return
|
| 38 |
-
|
| 39 |
|
| 40 |
-
def start_session(group_id: str) -> Tuple[str, str]:
|
| 41 |
-
if not group_id:
|
| 42 |
-
return "β Please enter a Group ID (e.g., G001).", ""
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
"π― Ready to generate challenges!"
|
| 60 |
)
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
def generate_challenges(session_id: str) -> str:
|
| 67 |
-
sid = session_id or current_session.get("session_id")
|
| 68 |
-
if not sid:
|
| 69 |
-
return "β Please provide a session ID (or start a session first)."
|
| 70 |
-
|
| 71 |
-
ok, result = safe_post(GENERATE_CHALLENGES_URL, {"session_id": sid}, timeout=60)
|
| 72 |
-
if not ok:
|
| 73 |
-
return f"β {result}"
|
| 74 |
-
|
| 75 |
-
if isinstance(result, dict):
|
| 76 |
-
challenges = result.get("challenges", [])
|
| 77 |
-
current_session["challenges"] = challenges
|
| 78 |
-
|
| 79 |
-
output_lines: List[str] = []
|
| 80 |
-
output_lines.append("β
**Challenges Generated!**\n")
|
| 81 |
-
synco_msg = result.get("synco_message", "")
|
| 82 |
-
if synco_msg:
|
| 83 |
-
output_lines.append(f"**π¬ Synco says:** {synco_msg}\n")
|
| 84 |
-
output_lines.append("---\n")
|
| 85 |
-
|
| 86 |
-
if not challenges:
|
| 87 |
-
output_lines.append("_No challenges returned from the API._")
|
| 88 |
else:
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
"session_id": sid,
|
| 124 |
-
"challenge_number": cnum,
|
| 125 |
-
"hint_level": hlvl
|
| 126 |
-
}, timeout=15)
|
| 127 |
-
if not ok:
|
| 128 |
-
return f"β {result}"
|
| 129 |
-
|
| 130 |
-
if isinstance(result, dict):
|
| 131 |
-
synco_msg = result.get("synco_message", "")
|
| 132 |
-
hint_text = result.get("hint", "") or str(result.get("hint", ""))
|
| 133 |
-
output = []
|
| 134 |
-
if synco_msg:
|
| 135 |
-
output.append(f"π‘ **{synco_msg}**\n")
|
| 136 |
-
output.append(f"π― Challenge {cnum} | Hint Level {hlvl}\n")
|
| 137 |
-
output.append("---\n")
|
| 138 |
-
output.append(hint_text or "_No hint provided by the API._")
|
| 139 |
-
return "\n\n".join(output)
|
| 140 |
-
|
| 141 |
-
return f"π‘ Response:\n```\n{result}\n```"
|
| 142 |
|
| 143 |
|
| 144 |
# ============================================
|
| 145 |
-
#
|
| 146 |
# ============================================
|
|
|
|
| 147 |
custom_css = """
|
|
|
|
| 148 |
.gradio-container {
|
| 149 |
-
background:
|
| 150 |
-
font-family:
|
| 151 |
-
color: #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
}
|
| 153 |
|
| 154 |
-
/* Tabs styling */
|
| 155 |
.tab-nav button {
|
| 156 |
-
background:
|
| 157 |
-
border: 1px solid
|
| 158 |
-
color:
|
| 159 |
-
font-weight:
|
|
|
|
|
|
|
|
|
|
| 160 |
transition: all 0.3s ease !important;
|
| 161 |
}
|
|
|
|
| 162 |
.tab-nav button:hover {
|
| 163 |
-
background:
|
| 164 |
-
border-color:
|
|
|
|
|
|
|
|
|
|
| 165 |
}
|
|
|
|
| 166 |
.tab-nav button.selected {
|
| 167 |
-
background:
|
| 168 |
-
border-color:
|
| 169 |
-
color:
|
| 170 |
-
|
|
|
|
| 171 |
}
|
| 172 |
|
| 173 |
/* Input fields */
|
| 174 |
input, textarea, select {
|
| 175 |
-
background:
|
| 176 |
-
border:
|
| 177 |
-
color: #
|
| 178 |
border-radius: 12px !important;
|
| 179 |
-
|
|
|
|
| 180 |
}
|
|
|
|
| 181 |
input:focus, textarea:focus, select:focus {
|
| 182 |
-
border-color:
|
| 183 |
-
box-shadow: 0 0
|
|
|
|
| 184 |
}
|
| 185 |
|
| 186 |
/* Buttons */
|
| 187 |
-
button {
|
| 188 |
-
background:
|
| 189 |
border: none !important;
|
| 190 |
-
color:
|
| 191 |
-
font-weight:
|
|
|
|
|
|
|
|
|
|
| 192 |
border-radius: 12px !important;
|
| 193 |
-
padding:
|
| 194 |
transition: all 0.3s ease !important;
|
| 195 |
-
box-shadow: 0
|
| 196 |
}
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
}
|
| 201 |
|
| 202 |
/* Output boxes */
|
| 203 |
-
.output-markdown {
|
| 204 |
-
background:
|
| 205 |
-
border:
|
| 206 |
-
border-radius:
|
| 207 |
-
padding:
|
| 208 |
-
color: #
|
|
|
|
| 209 |
}
|
| 210 |
|
| 211 |
/* Headers */
|
| 212 |
-
h1
|
| 213 |
-
background: linear-gradient(135deg,
|
| 214 |
-webkit-background-clip: text;
|
| 215 |
-webkit-text-fill-color: transparent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
font-weight: 800 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
}
|
| 218 |
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
padding: 2px 6px !important;
|
| 224 |
-
border-radius: 5px !important;
|
| 225 |
}
|
| 226 |
|
| 227 |
/* Links */
|
| 228 |
a {
|
| 229 |
-
color:
|
| 230 |
text-decoration: none !important;
|
| 231 |
-
font-weight:
|
|
|
|
| 232 |
}
|
|
|
|
| 233 |
a:hover {
|
| 234 |
-
color:
|
| 235 |
-
text-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
}
|
| 237 |
|
| 238 |
/* Scrollbar */
|
| 239 |
::-webkit-scrollbar {
|
| 240 |
-
width:
|
| 241 |
}
|
|
|
|
| 242 |
::-webkit-scrollbar-track {
|
| 243 |
-
background:
|
| 244 |
}
|
|
|
|
| 245 |
::-webkit-scrollbar-thumb {
|
| 246 |
-
background:
|
| 247 |
border-radius: 10px;
|
| 248 |
}
|
|
|
|
| 249 |
::-webkit-scrollbar-thumb:hover {
|
| 250 |
-
background:
|
| 251 |
}
|
| 252 |
-
"""
|
| 253 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
|
| 255 |
# ============================================
|
| 256 |
-
#
|
| 257 |
# ============================================
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
)
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
gr.
|
| 280 |
-
|
| 281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
with gr.Row():
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
with gr.Row():
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
## π About Synchrony
|
| 318 |
-
*Synchrony* is an AI-powered collaborative learning platform that:
|
| 319 |
-
β¨ Matches students with complementary learning styles
|
| 320 |
-
π€ Creates study groups based on chemistry scores
|
| 321 |
-
π― Generates personalized collaborative challenges
|
| 322 |
-
π‘ Provides adaptive hints for progressive learning
|
| 323 |
-
π Tracks progress and awards achievements
|
| 324 |
-
---
|
| 325 |
-
### π Quick Links
|
| 326 |
-
- π Student Registration Form (Add your Google Form link)
|
| 327 |
-
- π View Student Database (Add your Google Sheet link)
|
| 328 |
-
- π View Groups (Add your Google Sheet link)
|
| 329 |
-
---
|
| 330 |
-
### π Tech Stack
|
| 331 |
-
- *Frontend:* Gradio (Python)
|
| 332 |
-
- *Backend:* n8n Workflows
|
| 333 |
-
- *AI:* Groq API (Llama 3.3 70B)
|
| 334 |
-
- *Database:* Google Sheets
|
| 335 |
-
- *Matching Algorithm:* Chemistry Score System
|
| 336 |
-
---
|
| 337 |
-
### π₯ Created By
|
| 338 |
-
*Maryam Shanabli* | 2025-11-06
|
| 339 |
-
Powered by AI β’ Built for Students β’ Designed for Impact π
|
| 340 |
-
"""
|
| 341 |
)
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
test_gen_out = gr.JSON(label="Response")
|
| 359 |
-
def test_gen(sid):
|
| 360 |
-
ok, res = safe_post(GENERATE_CHALLENGES_URL, {"session_id": sid}, timeout=60)
|
| 361 |
-
return res if ok else {"error": res}
|
| 362 |
-
test_gen_btn.click(test_gen, inputs=[test_session], outputs=[test_gen_out])
|
| 363 |
-
|
| 364 |
-
with gr.Accordion("π‘ Test Request Hint", open=False):
|
| 365 |
-
test_hint_session = gr.Textbox(label="Session ID", value="S20251106160510")
|
| 366 |
-
test_hint_num = gr.Number(label="Challenge Number", value=1)
|
| 367 |
-
test_hint_lvl = gr.Number(label="Hint Level", value=1)
|
| 368 |
-
test_hint_btn = gr.Button("Test Request Hint")
|
| 369 |
-
test_hint_out = gr.JSON(label="Response")
|
| 370 |
-
def test_hint(sid, cnum, hlvl):
|
| 371 |
-
try:
|
| 372 |
-
ok, res = safe_post(REQUEST_HINT_URL, {
|
| 373 |
-
"session_id": sid,
|
| 374 |
-
"challenge_number": int(cnum),
|
| 375 |
-
"hint_level": int(hlvl)
|
| 376 |
-
}, timeout=20)
|
| 377 |
-
return res if ok else {"error": res}
|
| 378 |
-
except Exception as e:
|
| 379 |
-
return {"error": str(e)}
|
| 380 |
-
test_hint_btn.click(test_hint, inputs=[test_hint_session, test_hint_num, test_hint_lvl], outputs=[test_hint_out])
|
| 381 |
-
|
| 382 |
-
# Footer
|
| 383 |
-
gr.Markdown("""---
|
| 384 |
-
### π *Synchrony* | Collaborative Learning, Powered by AI
|
| 385 |
-
Made with π by Maryam Shanabli | 2025
|
| 386 |
""")
|
| 387 |
|
| 388 |
-
|
| 389 |
# ============================================
|
| 390 |
-
#
|
| 391 |
# ============================================
|
|
|
|
| 392 |
if __name__ == "__main__":
|
| 393 |
app.launch(
|
| 394 |
server_name="0.0.0.0",
|
| 395 |
server_port=7860,
|
| 396 |
share=True,
|
| 397 |
-
show_error=True
|
| 398 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
+
import json
|
| 4 |
from datetime import datetime
|
|
|
|
| 5 |
|
| 6 |
# ============================================
|
| 7 |
+
# π SYNCHRONY - STUDENT PORTAL (GEN Z EDITION)
|
| 8 |
# ============================================
|
| 9 |
+
|
| 10 |
+
# Your n8n webhook URLs
|
| 11 |
BASE_URL = "https://maryyam.app.n8n.cloud/webhook-test"
|
| 12 |
START_SESSION_URL = f"{BASE_URL}/start-session"
|
| 13 |
GENERATE_CHALLENGES_URL = f"{BASE_URL}/generate-challenges"
|
| 14 |
REQUEST_HINT_URL = f"{BASE_URL}/request-hint"
|
| 15 |
|
| 16 |
+
# Google Form URL
|
| 17 |
+
REGISTRATION_FORM = "https://docs.google.com/forms/d/e/1FAIpQLSfJFGx-yd0FPIuRYLUJut3BOOiQ14x_5DYheWpgrUqcHdQaCA/viewform"
|
| 18 |
+
|
| 19 |
+
# Mock student session (in production, this would be from login)
|
| 20 |
+
current_student = {
|
| 21 |
+
"name": None,
|
| 22 |
+
"email": None,
|
| 23 |
+
"group_id": None,
|
| 24 |
+
"session_id": None,
|
| 25 |
+
"team_members": [],
|
| 26 |
+
"challenges": []
|
| 27 |
+
}
|
| 28 |
|
| 29 |
+
# Mock chat history
|
| 30 |
+
chat_history = []
|
| 31 |
|
| 32 |
# ============================================
|
| 33 |
+
# π§ API FUNCTIONS
|
| 34 |
# ============================================
|
| 35 |
+
|
| 36 |
+
def lookup_student(email):
|
| 37 |
+
"""Look up student by email and get their group"""
|
| 38 |
+
# In production, this would query Google Sheets
|
| 39 |
+
# For demo, we'll use mock data
|
| 40 |
+
|
| 41 |
+
# Mock student data
|
| 42 |
+
mock_students = {
|
| 43 |
+
"layla@university.edu": {
|
| 44 |
+
"name": "Layla Mahmoud",
|
| 45 |
+
"email": "layla@university.edu",
|
| 46 |
+
"group_id": "G001",
|
| 47 |
+
"topic": "Binary Search Trees",
|
| 48 |
+
"session_id": "S20251106160510"
|
| 49 |
+
},
|
| 50 |
+
"omar@university.edu": {
|
| 51 |
+
"name": "Omar Khalil",
|
| 52 |
+
"email": "omar@university.edu",
|
| 53 |
+
"group_id": "G001",
|
| 54 |
+
"topic": "Linked Lists",
|
| 55 |
+
"session_id": "S20251106160510"
|
| 56 |
+
},
|
| 57 |
+
"khaled@university.edu": {
|
| 58 |
+
"name": "Khaled Ibrahim",
|
| 59 |
+
"email": "khaled@university.edu",
|
| 60 |
+
"group_id": "G001",
|
| 61 |
+
"topic": "Queues",
|
| 62 |
+
"session_id": "S20251106160510"
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
if email.lower() in mock_students:
|
| 67 |
+
student = mock_students[email.lower()]
|
| 68 |
+
current_student.update(student)
|
| 69 |
+
|
| 70 |
+
# Get team members
|
| 71 |
+
team = [s for s in mock_students.values() if s["group_id"] == student["group_id"]]
|
| 72 |
+
current_student["team_members"] = team
|
| 73 |
+
|
| 74 |
+
return True, f"β
Welcome back, {student['name']}!"
|
| 75 |
+
else:
|
| 76 |
+
return False, "β Email not found. Please register first!"
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def get_team_info():
|
| 80 |
+
"""Display team information"""
|
| 81 |
+
if not current_student["name"]:
|
| 82 |
+
return "β οΈ Please login first!"
|
| 83 |
+
|
| 84 |
+
output = f"## π₯ Your Study Team - {current_student['group_id']}\n\n"
|
| 85 |
+
output += f"**Session ID:** `{current_student['session_id']}`\n\n"
|
| 86 |
+
output += "---\n\n"
|
| 87 |
+
|
| 88 |
+
for member in current_student["team_members"]:
|
| 89 |
+
is_you = " **(YOU)**" if member["email"] == current_student["email"] else ""
|
| 90 |
+
output += f"### π {member['name']}{is_you}\n"
|
| 91 |
+
output += f"**Topic:** {member['topic']}\n"
|
| 92 |
+
output += f"**Email:** {member['email']}\n\n"
|
| 93 |
+
|
| 94 |
+
return output
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def load_challenges():
|
| 98 |
+
"""Load challenges for current session"""
|
| 99 |
+
if not current_student["session_id"]:
|
| 100 |
+
return "β οΈ No active session. Please login first!"
|
| 101 |
+
|
| 102 |
try:
|
| 103 |
+
response = requests.post(
|
| 104 |
+
GENERATE_CHALLENGES_URL,
|
| 105 |
+
json={"session_id": current_student["session_id"]},
|
| 106 |
+
headers={"Content-Type": "application/json"},
|
| 107 |
+
timeout=60
|
| 108 |
+
)
|
| 109 |
+
|
| 110 |
+
if response.status_code == 200:
|
| 111 |
+
data = response.json()
|
| 112 |
+
current_student["challenges"] = data.get("challenges", [])
|
| 113 |
+
|
| 114 |
+
output = f"# π― Your Collaborative Challenges\n\n"
|
| 115 |
+
output += f"π¬ **Synco says:** {data.get('synco_message', '')}\n\n"
|
| 116 |
+
output += "---\n\n"
|
| 117 |
+
|
| 118 |
+
for i, challenge in enumerate(current_student["challenges"], 1):
|
| 119 |
+
chal = challenge.get('json', challenge)
|
| 120 |
+
output += f"## π― Challenge {i}\n\n"
|
| 121 |
+
output += f"{chal.get('description', 'No description')}\n\n"
|
| 122 |
+
output += f"**π Topics:** {chal.get('topics_involved', 'N/A')}\n\n"
|
| 123 |
+
output += f"π‘ *Stuck? Request a hint below!*\n\n"
|
| 124 |
+
output += "---\n\n"
|
| 125 |
+
|
| 126 |
+
return output
|
| 127 |
else:
|
| 128 |
+
return f"β Error loading challenges: {response.status_code}"
|
| 129 |
+
|
| 130 |
except Exception as e:
|
| 131 |
+
return f"β Connection Error: {str(e)}"
|
|
|
|
| 132 |
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
+
def request_hint(challenge_num, hint_level):
|
| 135 |
+
"""Request a hint for a specific challenge"""
|
| 136 |
+
if not current_student["session_id"]:
|
| 137 |
+
return "β οΈ No active session. Please login first!"
|
| 138 |
+
|
| 139 |
+
try:
|
| 140 |
+
response = requests.post(
|
| 141 |
+
REQUEST_HINT_URL,
|
| 142 |
+
json={
|
| 143 |
+
"session_id": current_student["session_id"],
|
| 144 |
+
"challenge_number": int(challenge_num),
|
| 145 |
+
"hint_level": int(hint_level)
|
| 146 |
+
},
|
| 147 |
+
headers={"Content-Type": "application/json"},
|
| 148 |
+
timeout=10
|
|
|
|
| 149 |
)
|
| 150 |
+
|
| 151 |
+
if response.status_code == 200:
|
| 152 |
+
data = response.json()
|
| 153 |
+
return f"## {data.get('synco_message', '')}\n\n{data.get('hint', '')}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
else:
|
| 155 |
+
return f"β Error: {response.status_code}"
|
| 156 |
+
|
| 157 |
+
except Exception as e:
|
| 158 |
+
return f"β Connection Error: {str(e)}"
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def send_message(message, history):
|
| 162 |
+
"""Send a chat message (simulated for demo)"""
|
| 163 |
+
if not message.strip():
|
| 164 |
+
return history, ""
|
| 165 |
+
|
| 166 |
+
# Add user message
|
| 167 |
+
history.append({
|
| 168 |
+
"role": "user",
|
| 169 |
+
"content": f"**{current_student['name'] or 'You'}:** {message}"
|
| 170 |
+
})
|
| 171 |
+
|
| 172 |
+
# Simulate team member responses
|
| 173 |
+
responses = [
|
| 174 |
+
f"**Omar:** That's a great point! Let me add to that...",
|
| 175 |
+
f"**Layla:** I think we should also consider...",
|
| 176 |
+
f"**Khaled:** Interesting! In my topic, we do it differently...",
|
| 177 |
+
f"**Synco (AI):** Great discussion! Keep going! π‘"
|
| 178 |
+
]
|
| 179 |
+
|
| 180 |
+
import random
|
| 181 |
+
response = random.choice(responses)
|
| 182 |
+
|
| 183 |
+
history.append({
|
| 184 |
+
"role": "assistant",
|
| 185 |
+
"content": response
|
| 186 |
+
})
|
| 187 |
+
|
| 188 |
+
return history, ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
|
| 191 |
# ============================================
|
| 192 |
+
# π¨ CUSTOM CSS - PURE BLACK GEN Z STYLE
|
| 193 |
# ============================================
|
| 194 |
+
|
| 195 |
custom_css = """
|
| 196 |
+
/* Pure Black Gen Z Background */
|
| 197 |
.gradio-container {
|
| 198 |
+
background: #000000 !important;
|
| 199 |
+
font-family: 'SF Pro Display', 'Inter', 'Segoe UI', sans-serif !important;
|
| 200 |
+
color: #ffffff !important;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
/* Neon accent colors */
|
| 204 |
+
:root {
|
| 205 |
+
--neon-pink: #ff00ff;
|
| 206 |
+
--neon-cyan: #00ffff;
|
| 207 |
+
--neon-purple: #9d00ff;
|
| 208 |
+
--neon-green: #00ff88;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
/* Main container */
|
| 212 |
+
.contain {
|
| 213 |
+
background: #000000 !important;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
/* Tabs */
|
| 217 |
+
.tab-nav {
|
| 218 |
+
background: #111111 !important;
|
| 219 |
+
border-bottom: 2px solid var(--neon-pink) !important;
|
| 220 |
}
|
| 221 |
|
|
|
|
| 222 |
.tab-nav button {
|
| 223 |
+
background: #1a1a1a !important;
|
| 224 |
+
border: 1px solid #333333 !important;
|
| 225 |
+
color: var(--neon-cyan) !important;
|
| 226 |
+
font-weight: 700 !important;
|
| 227 |
+
font-size: 16px !important;
|
| 228 |
+
text-transform: uppercase !important;
|
| 229 |
+
letter-spacing: 1px !important;
|
| 230 |
transition: all 0.3s ease !important;
|
| 231 |
}
|
| 232 |
+
|
| 233 |
.tab-nav button:hover {
|
| 234 |
+
background: #222222 !important;
|
| 235 |
+
border-color: var(--neon-pink) !important;
|
| 236 |
+
color: var(--neon-pink) !important;
|
| 237 |
+
transform: translateY(-2px) !important;
|
| 238 |
+
box-shadow: 0 5px 20px rgba(255, 0, 255, 0.4) !important;
|
| 239 |
}
|
| 240 |
+
|
| 241 |
.tab-nav button.selected {
|
| 242 |
+
background: linear-gradient(135deg, var(--neon-pink) 0%, var(--neon-purple) 100%) !important;
|
| 243 |
+
border-color: var(--neon-pink) !important;
|
| 244 |
+
color: #000000 !important;
|
| 245 |
+
font-weight: 900 !important;
|
| 246 |
+
box-shadow: 0 0 30px rgba(255, 0, 255, 0.8) !important;
|
| 247 |
}
|
| 248 |
|
| 249 |
/* Input fields */
|
| 250 |
input, textarea, select {
|
| 251 |
+
background: #1a1a1a !important;
|
| 252 |
+
border: 2px solid #333333 !important;
|
| 253 |
+
color: #ffffff !important;
|
| 254 |
border-radius: 12px !important;
|
| 255 |
+
font-size: 16px !important;
|
| 256 |
+
padding: 12px !important;
|
| 257 |
}
|
| 258 |
+
|
| 259 |
input:focus, textarea:focus, select:focus {
|
| 260 |
+
border-color: var(--neon-cyan) !important;
|
| 261 |
+
box-shadow: 0 0 20px rgba(0, 255, 255, 0.5) !important;
|
| 262 |
+
outline: none !important;
|
| 263 |
}
|
| 264 |
|
| 265 |
/* Buttons */
|
| 266 |
+
button.primary {
|
| 267 |
+
background: linear-gradient(135deg, var(--neon-pink) 0%, var(--neon-purple) 100%) !important;
|
| 268 |
border: none !important;
|
| 269 |
+
color: #000000 !important;
|
| 270 |
+
font-weight: 900 !important;
|
| 271 |
+
font-size: 18px !important;
|
| 272 |
+
text-transform: uppercase !important;
|
| 273 |
+
letter-spacing: 2px !important;
|
| 274 |
border-radius: 12px !important;
|
| 275 |
+
padding: 16px 32px !important;
|
| 276 |
transition: all 0.3s ease !important;
|
| 277 |
+
box-shadow: 0 5px 30px rgba(255, 0, 255, 0.5) !important;
|
| 278 |
}
|
| 279 |
+
|
| 280 |
+
button.primary:hover {
|
| 281 |
+
transform: translateY(-4px) scale(1.05) !important;
|
| 282 |
+
box-shadow: 0 10px 50px rgba(255, 0, 255, 0.8) !important;
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
button.secondary {
|
| 286 |
+
background: linear-gradient(135deg, var(--neon-cyan) 0%, var(--neon-green) 100%) !important;
|
| 287 |
+
border: none !important;
|
| 288 |
+
color: #000000 !important;
|
| 289 |
+
font-weight: 800 !important;
|
| 290 |
+
border-radius: 12px !important;
|
| 291 |
+
padding: 12px 24px !important;
|
| 292 |
}
|
| 293 |
|
| 294 |
/* Output boxes */
|
| 295 |
+
.output-markdown, .prose {
|
| 296 |
+
background: #0a0a0a !important;
|
| 297 |
+
border: 2px solid #222222 !important;
|
| 298 |
+
border-radius: 16px !important;
|
| 299 |
+
padding: 24px !important;
|
| 300 |
+
color: #e0e0e0 !important;
|
| 301 |
+
box-shadow: inset 0 0 20px rgba(0, 255, 255, 0.1) !important;
|
| 302 |
}
|
| 303 |
|
| 304 |
/* Headers */
|
| 305 |
+
h1 {
|
| 306 |
+
background: linear-gradient(135deg, var(--neon-pink) 0%, var(--neon-cyan) 100%);
|
| 307 |
-webkit-background-clip: text;
|
| 308 |
-webkit-text-fill-color: transparent;
|
| 309 |
+
background-clip: text;
|
| 310 |
+
font-weight: 900 !important;
|
| 311 |
+
font-size: 48px !important;
|
| 312 |
+
text-transform: uppercase !important;
|
| 313 |
+
letter-spacing: 3px !important;
|
| 314 |
+
text-align: center !important;
|
| 315 |
+
margin: 20px 0 !important;
|
| 316 |
+
text-shadow: 0 0 30px rgba(255, 0, 255, 0.5) !important;
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
h2 {
|
| 320 |
+
color: var(--neon-cyan) !important;
|
| 321 |
font-weight: 800 !important;
|
| 322 |
+
font-size: 32px !important;
|
| 323 |
+
text-transform: uppercase !important;
|
| 324 |
+
letter-spacing: 2px !important;
|
| 325 |
+
margin: 16px 0 !important;
|
| 326 |
}
|
| 327 |
|
| 328 |
+
h3 {
|
| 329 |
+
color: var(--neon-pink) !important;
|
| 330 |
+
font-weight: 700 !important;
|
| 331 |
+
font-size: 24px !important;
|
|
|
|
|
|
|
| 332 |
}
|
| 333 |
|
| 334 |
/* Links */
|
| 335 |
a {
|
| 336 |
+
color: var(--neon-cyan) !important;
|
| 337 |
text-decoration: none !important;
|
| 338 |
+
font-weight: 700 !important;
|
| 339 |
+
transition: all 0.3s ease !important;
|
| 340 |
}
|
| 341 |
+
|
| 342 |
a:hover {
|
| 343 |
+
color: var(--neon-pink) !important;
|
| 344 |
+
text-shadow: 0 0 10px rgba(255, 0, 255, 0.8) !important;
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
/* Code blocks */
|
| 348 |
+
code {
|
| 349 |
+
background: #1a1a1a !important;
|
| 350 |
+
color: var(--neon-green) !important;
|
| 351 |
+
padding: 4px 8px !important;
|
| 352 |
+
border-radius: 6px !important;
|
| 353 |
+
border: 1px solid var(--neon-cyan) !important;
|
| 354 |
+
font-family: 'Fira Code', monospace !important;
|
| 355 |
}
|
| 356 |
|
| 357 |
/* Scrollbar */
|
| 358 |
::-webkit-scrollbar {
|
| 359 |
+
width: 12px;
|
| 360 |
}
|
| 361 |
+
|
| 362 |
::-webkit-scrollbar-track {
|
| 363 |
+
background: #0a0a0a;
|
| 364 |
}
|
| 365 |
+
|
| 366 |
::-webkit-scrollbar-thumb {
|
| 367 |
+
background: linear-gradient(135deg, var(--neon-pink) 0%, var(--neon-cyan) 100%);
|
| 368 |
border-radius: 10px;
|
| 369 |
}
|
| 370 |
+
|
| 371 |
::-webkit-scrollbar-thumb:hover {
|
| 372 |
+
background: linear-gradient(135deg, var(--neon-cyan) 0%, var(--neon-pink) 100%);
|
| 373 |
}
|
|
|
|
| 374 |
|
| 375 |
+
/* Labels */
|
| 376 |
+
label {
|
| 377 |
+
color: var(--neon-cyan) !important;
|
| 378 |
+
font-weight: 700 !important;
|
| 379 |
+
font-size: 14px !important;
|
| 380 |
+
text-transform: uppercase !important;
|
| 381 |
+
letter-spacing: 1px !important;
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
/* Chatbot styling */
|
| 385 |
+
.message-wrap {
|
| 386 |
+
background: #1a1a1a !important;
|
| 387 |
+
border: 1px solid #333333 !important;
|
| 388 |
+
border-radius: 12px !important;
|
| 389 |
+
margin: 8px 0 !important;
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
.message.user {
|
| 393 |
+
background: linear-gradient(135deg, var(--neon-pink) 0%, var(--neon-purple) 100%) !important;
|
| 394 |
+
color: #ffffff !important;
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
.message.bot {
|
| 398 |
+
background: #222222 !important;
|
| 399 |
+
border: 1px solid var(--neon-cyan) !important;
|
| 400 |
+
color: #ffffff !important;
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
/* Glow effects */
|
| 404 |
+
.glow {
|
| 405 |
+
animation: glow 2s ease-in-out infinite alternate;
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
@keyframes glow {
|
| 409 |
+
from {
|
| 410 |
+
box-shadow: 0 0 10px var(--neon-pink), 0 0 20px var(--neon-pink);
|
| 411 |
+
}
|
| 412 |
+
to {
|
| 413 |
+
box-shadow: 0 0 20px var(--neon-cyan), 0 0 40px var(--neon-cyan);
|
| 414 |
+
}
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
/* Dropdown menus */
|
| 418 |
+
.dropdown-container {
|
| 419 |
+
background: #1a1a1a !important;
|
| 420 |
+
border: 2px solid #333333 !important;
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
/* Accordions */
|
| 424 |
+
.accordion {
|
| 425 |
+
background: #111111 !important;
|
| 426 |
+
border: 1px solid var(--neon-pink) !important;
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
/* Info boxes */
|
| 430 |
+
.info {
|
| 431 |
+
background: rgba(0, 255, 255, 0.1) !important;
|
| 432 |
+
border-left: 4px solid var(--neon-cyan) !important;
|
| 433 |
+
padding: 16px !important;
|
| 434 |
+
border-radius: 8px !important;
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
.warning {
|
| 438 |
+
background: rgba(255, 0, 255, 0.1) !important;
|
| 439 |
+
border-left: 4px solid var(--neon-pink) !important;
|
| 440 |
+
padding: 16px !important;
|
| 441 |
+
border-radius: 8px !important;
|
| 442 |
+
}
|
| 443 |
+
"""
|
| 444 |
|
| 445 |
# ============================================
|
| 446 |
+
# π GRADIO INTERFACE
|
| 447 |
# ============================================
|
| 448 |
+
|
| 449 |
+
with gr.Blocks(css=custom_css, title="π SYNCHRONY - Student Portal", theme=gr.themes.Base()) as app:
|
| 450 |
+
|
| 451 |
+
# ============================================
|
| 452 |
+
# HEADER
|
| 453 |
+
# ============================================
|
| 454 |
+
gr.Markdown("""
|
| 455 |
+
# π SYNCHRONY
|
| 456 |
+
## *where students teach students* π«
|
| 457 |
+
""")
|
| 458 |
+
|
| 459 |
+
# ============================================
|
| 460 |
+
# TAB 1: HOME / LOGIN
|
| 461 |
+
# ============================================
|
| 462 |
+
with gr.Tab("π HOME"):
|
| 463 |
+
gr.Markdown("""
|
| 464 |
+
## welcome to synchrony β¨
|
| 465 |
+
|
| 466 |
+
*the ai-powered study platform where you learn by teaching*
|
| 467 |
+
""")
|
| 468 |
+
|
| 469 |
+
with gr.Row():
|
| 470 |
+
with gr.Column(scale=1):
|
| 471 |
+
gr.Markdown("""
|
| 472 |
+
### π new here?
|
| 473 |
+
|
| 474 |
+
register now and get matched with your perfect study squad!
|
| 475 |
+
""")
|
| 476 |
+
|
| 477 |
+
register_btn = gr.Button("π REGISTER NOW", variant="primary", size="lg")
|
| 478 |
+
|
| 479 |
+
gr.Markdown("""
|
| 480 |
+
### π already registered?
|
| 481 |
+
|
| 482 |
+
enter your email to access your study session
|
| 483 |
+
""")
|
| 484 |
+
|
| 485 |
+
email_input = gr.Textbox(
|
| 486 |
+
label="π§ university email",
|
| 487 |
+
placeholder="your.email@university.edu"
|
| 488 |
+
)
|
| 489 |
+
|
| 490 |
+
login_btn = gr.Button("π LOGIN", variant="secondary")
|
| 491 |
+
login_output = gr.Markdown()
|
| 492 |
+
|
| 493 |
+
# Register button opens Google Form
|
| 494 |
+
register_btn.click(
|
| 495 |
+
fn=lambda: gr.update(visible=True),
|
| 496 |
+
outputs=None
|
| 497 |
+
).then(
|
| 498 |
+
fn=None,
|
| 499 |
+
js=f"() => window.open('{REGISTRATION_FORM}', '_blank')"
|
| 500 |
+
)
|
| 501 |
+
|
| 502 |
+
# Login button
|
| 503 |
+
login_btn.click(
|
| 504 |
+
fn=lookup_student,
|
| 505 |
+
inputs=[email_input],
|
| 506 |
+
outputs=[login_output, login_output]
|
| 507 |
+
)
|
| 508 |
+
|
| 509 |
+
# ============================================
|
| 510 |
+
# TAB 2: MY TEAM
|
| 511 |
+
# ============================================
|
| 512 |
+
with gr.Tab("π₯ MY TEAM"):
|
| 513 |
+
gr.Markdown("""
|
| 514 |
+
## your study squad π₯
|
| 515 |
+
|
| 516 |
+
meet your teammates and see what everyone's working on
|
| 517 |
+
""")
|
| 518 |
+
|
| 519 |
+
team_display = gr.Markdown()
|
| 520 |
+
|
| 521 |
+
refresh_team_btn = gr.Button("π REFRESH TEAM INFO", variant="secondary")
|
| 522 |
+
|
| 523 |
+
refresh_team_btn.click(
|
| 524 |
+
fn=get_team_info,
|
| 525 |
+
outputs=[team_display]
|
| 526 |
+
)
|
| 527 |
+
|
| 528 |
+
# Auto-load on tab open
|
| 529 |
+
app.load(
|
| 530 |
+
fn=get_team_info,
|
| 531 |
+
outputs=[team_display]
|
| 532 |
+
)
|
| 533 |
+
|
| 534 |
+
# ============================================
|
| 535 |
+
# TAB 3: CHALLENGES
|
| 536 |
+
# ============================================
|
| 537 |
+
with gr.Tab("π― CHALLENGES"):
|
| 538 |
+
gr.Markdown("""
|
| 539 |
+
## your collaborative challenges πͺ
|
| 540 |
+
|
| 541 |
+
work together, learn from each other, level up!
|
| 542 |
+
""")
|
| 543 |
+
|
| 544 |
+
load_challenges_btn = gr.Button("π₯ LOAD CHALLENGES", variant="primary")
|
| 545 |
+
challenges_display = gr.Markdown()
|
| 546 |
+
|
| 547 |
+
load_challenges_btn.click(
|
| 548 |
+
fn=load_challenges,
|
| 549 |
+
outputs=[challenges_display]
|
| 550 |
+
)
|
| 551 |
+
|
| 552 |
+
# ============================================
|
| 553 |
+
# TAB 4: HINTS
|
| 554 |
+
# ============================================
|
| 555 |
+
with gr.Tab("π‘ HINTS"):
|
| 556 |
+
gr.Markdown("""
|
| 557 |
+
## need help? no worries! π€
|
| 558 |
+
|
| 559 |
+
synco's got your back with adaptive hints
|
| 560 |
+
""")
|
| 561 |
+
|
| 562 |
with gr.Row():
|
| 563 |
+
challenge_select = gr.Dropdown(
|
| 564 |
+
label="π― select challenge",
|
| 565 |
+
choices=["1", "2", "3"],
|
| 566 |
+
value="1"
|
| 567 |
+
)
|
| 568 |
+
|
| 569 |
+
hint_level_select = gr.Dropdown(
|
| 570 |
+
label="π‘ hint level",
|
| 571 |
+
choices=["1 - gentle nudge π€", "2 - clearer guidance π", "3 - almost there π―"],
|
| 572 |
+
value="1 - gentle nudge π€"
|
| 573 |
+
)
|
| 574 |
+
|
| 575 |
+
get_hint_btn = gr.Button("π‘ GET HINT", variant="primary")
|
| 576 |
+
hint_display = gr.Markdown()
|
| 577 |
+
|
| 578 |
+
def extract_hint_level(choice):
|
| 579 |
+
return choice.split(" - ")[0]
|
| 580 |
+
|
| 581 |
+
get_hint_btn.click(
|
| 582 |
+
fn=lambda c, h: request_hint(c, extract_hint_level(h)),
|
| 583 |
+
inputs=[challenge_select, hint_level_select],
|
| 584 |
+
outputs=[hint_display]
|
| 585 |
+
)
|
| 586 |
+
|
| 587 |
+
# ============================================
|
| 588 |
+
# TAB 5: TEAM CHAT
|
| 589 |
+
# ============================================
|
| 590 |
+
with gr.Tab("π¬ CHAT"):
|
| 591 |
+
gr.Markdown("""
|
| 592 |
+
## team chat π¬
|
| 593 |
+
|
| 594 |
+
discuss challenges, share ideas, help each other out!
|
| 595 |
+
|
| 596 |
+
*demo mode - simulated responses*
|
| 597 |
+
""")
|
| 598 |
+
|
| 599 |
+
chatbot = gr.Chatbot(
|
| 600 |
+
value=[],
|
| 601 |
+
label="π¬ team chat",
|
| 602 |
+
height=400,
|
| 603 |
+
type="messages"
|
| 604 |
+
)
|
| 605 |
+
|
| 606 |
with gr.Row():
|
| 607 |
+
msg_input = gr.Textbox(
|
| 608 |
+
label="",
|
| 609 |
+
placeholder="type your message...",
|
| 610 |
+
scale=4
|
| 611 |
+
)
|
| 612 |
+
send_btn = gr.Button("π€ SEND", variant="primary", scale=1)
|
| 613 |
+
|
| 614 |
+
send_btn.click(
|
| 615 |
+
fn=send_message,
|
| 616 |
+
inputs=[msg_input, chatbot],
|
| 617 |
+
outputs=[chatbot, msg_input]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 618 |
)
|
| 619 |
+
|
| 620 |
+
msg_input.submit(
|
| 621 |
+
fn=send_message,
|
| 622 |
+
inputs=[msg_input, chatbot],
|
| 623 |
+
outputs=[chatbot, msg_input]
|
| 624 |
+
)
|
| 625 |
+
|
| 626 |
+
# ============================================
|
| 627 |
+
# FOOTER
|
| 628 |
+
# ============================================
|
| 629 |
+
gr.Markdown("""
|
| 630 |
+
---
|
| 631 |
+
|
| 632 |
+
### π **synchrony** | *powered by ai, built for students* π
|
| 633 |
+
|
| 634 |
+
made with π₯ by maryam shanabli | 2025
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 635 |
""")
|
| 636 |
|
|
|
|
| 637 |
# ============================================
|
| 638 |
+
# π LAUNCH APP
|
| 639 |
# ============================================
|
| 640 |
+
|
| 641 |
if __name__ == "__main__":
|
| 642 |
app.launch(
|
| 643 |
server_name="0.0.0.0",
|
| 644 |
server_port=7860,
|
| 645 |
share=True,
|
| 646 |
+
show_error=True,
|
| 647 |
+
favicon_path=None
|
| 648 |
+
)
|