Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,7 +46,7 @@ def image_to_base64(image_path):
|
|
| 46 |
mime = "image/png"
|
| 47 |
return f"data:{mime};base64,{encoded_string}"
|
| 48 |
|
| 49 |
-
# ================== User Guide Content (
|
| 50 |
USER_GUIDE_SECTIONS = {
|
| 51 |
"getting_started": """
|
| 52 |
Welcome to **Clare — Your Personalized AI Tutor**.
|
|
@@ -197,33 +197,41 @@ CUSTOM_CSS = """
|
|
| 197 |
.main-user-guide {
|
| 198 |
border: none !important;
|
| 199 |
background: transparent !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
}
|
| 201 |
.main-user-guide > .label-wrap span {
|
| 202 |
-
font-size: 1.
|
| 203 |
font-weight: 800 !important; /* 加粗 */
|
| 204 |
color: #111827 !important; /* 深黑色 */
|
| 205 |
}
|
| 206 |
|
| 207 |
-
/* 2. 内部子菜单 (小标题) */
|
| 208 |
.clean-accordion {
|
| 209 |
border: none !important;
|
| 210 |
background: transparent !important;
|
| 211 |
box-shadow: none !important;
|
| 212 |
margin-bottom: 0px !important;
|
| 213 |
padding: 0 !important;
|
|
|
|
| 214 |
}
|
| 215 |
.clean-accordion > .label-wrap {
|
| 216 |
-
padding:
|
| 217 |
-
border
|
|
|
|
|
|
|
| 218 |
}
|
| 219 |
.clean-accordion > .label-wrap span {
|
| 220 |
font-size: 0.9rem !important; /* 比主标题小 */
|
| 221 |
font-weight: 500 !important; /* 中等粗细 */
|
| 222 |
-
color: #
|
| 223 |
}
|
| 224 |
-
.clean-accordion > .label-wrap:hover
|
| 225 |
-
color: #
|
| 226 |
-
text-decoration: underline;
|
| 227 |
}
|
| 228 |
|
| 229 |
/* Action 按钮加粗 & Tooltip */
|
|
@@ -297,10 +305,8 @@ with gr.Blocks(title="Clare – Hanbridge AI Teaching Assistant", css=CUSTOM_CSS
|
|
| 297 |
info="See User Guide for mode definitions details."
|
| 298 |
)
|
| 299 |
|
| 300 |
-
# User Guide (
|
| 301 |
-
# 给最外层加上 elem_classes="main-user-guide"
|
| 302 |
with gr.Accordion("User Guide", open=True, elem_classes="main-user-guide"):
|
| 303 |
-
# 子项只保留 clean-accordion 样式
|
| 304 |
with gr.Accordion("Getting Started", open=False, elem_classes="clean-accordion"): gr.Markdown(USER_GUIDE_SECTIONS["getting_started"])
|
| 305 |
with gr.Accordion("Mode Definition", open=False, elem_classes="clean-accordion"): gr.Markdown(USER_GUIDE_SECTIONS["mode_definition"])
|
| 306 |
with gr.Accordion("How Clare Works", open=False, elem_classes="clean-accordion"): gr.Markdown(USER_GUIDE_SECTIONS["how_clare_works"])
|
|
@@ -328,22 +334,28 @@ with gr.Blocks(title="Clare – Hanbridge AI Teaching Assistant", css=CUSTOM_CSS
|
|
| 328 |
# === [Center Main] ===
|
| 329 |
with gr.Column(scale=3):
|
| 330 |
|
| 331 |
-
# Upload & Memory Line Row
|
| 332 |
with gr.Row():
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
file_types=[".docx", ".pdf", ".pptx"],
|
| 337 |
-
file_count="single",
|
| 338 |
-
height=160,
|
| 339 |
-
label="Upload file (.docx/.pdf/.pptx)"
|
| 340 |
-
)
|
| 341 |
with gr.Row():
|
| 342 |
-
|
| 343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
|
| 345 |
-
# Memory Line
|
| 346 |
-
with gr.Column(scale=1):
|
| 347 |
with gr.Group(elem_classes="memory-line-box"):
|
| 348 |
gr.HTML(
|
| 349 |
f"""
|
|
@@ -379,8 +391,8 @@ with gr.Blocks(title="Clare – Hanbridge AI Teaching Assistant", css=CUSTOM_CSS
|
|
| 379 |
# === [Right Sidebar] ===
|
| 380 |
with gr.Column(scale=1, min_width=180):
|
| 381 |
|
| 382 |
-
# Spacer
|
| 383 |
-
gr.HTML("<div style='height:
|
| 384 |
|
| 385 |
gr.Markdown("### Actions")
|
| 386 |
|
|
|
|
| 46 |
mime = "image/png"
|
| 47 |
return f"data:{mime};base64,{encoded_string}"
|
| 48 |
|
| 49 |
+
# ================== User Guide Content (已去除标题) ==================
|
| 50 |
USER_GUIDE_SECTIONS = {
|
| 51 |
"getting_started": """
|
| 52 |
Welcome to **Clare — Your Personalized AI Tutor**.
|
|
|
|
| 197 |
.main-user-guide {
|
| 198 |
border: none !important;
|
| 199 |
background: transparent !important;
|
| 200 |
+
box-shadow: none !important;
|
| 201 |
+
}
|
| 202 |
+
.main-user-guide > .label-wrap {
|
| 203 |
+
border: none !important;
|
| 204 |
+
background: transparent !important;
|
| 205 |
+
padding: 10px 0 !important;
|
| 206 |
}
|
| 207 |
.main-user-guide > .label-wrap span {
|
| 208 |
+
font-size: 1.3rem !important; /* 加大 */
|
| 209 |
font-weight: 800 !important; /* 加粗 */
|
| 210 |
color: #111827 !important; /* 深黑色 */
|
| 211 |
}
|
| 212 |
|
| 213 |
+
/* 2. 内部子菜单 (小标题 - 列表风格) */
|
| 214 |
.clean-accordion {
|
| 215 |
border: none !important;
|
| 216 |
background: transparent !important;
|
| 217 |
box-shadow: none !important;
|
| 218 |
margin-bottom: 0px !important;
|
| 219 |
padding: 0 !important;
|
| 220 |
+
border-radius: 0 !important;
|
| 221 |
}
|
| 222 |
.clean-accordion > .label-wrap {
|
| 223 |
+
padding: 8px 5px !important;
|
| 224 |
+
border: none !important;
|
| 225 |
+
background: transparent !important;
|
| 226 |
+
border-bottom: 1px solid #e5e7eb !important; /* 细分隔线 */
|
| 227 |
}
|
| 228 |
.clean-accordion > .label-wrap span {
|
| 229 |
font-size: 0.9rem !important; /* 比主标题小 */
|
| 230 |
font-weight: 500 !important; /* 中等粗细 */
|
| 231 |
+
color: #374151 !important; /* 深灰色 */
|
| 232 |
}
|
| 233 |
+
.clean-accordion > .label-wrap:hover {
|
| 234 |
+
background-color: #f9fafb !important;
|
|
|
|
| 235 |
}
|
| 236 |
|
| 237 |
/* Action 按钮加粗 & Tooltip */
|
|
|
|
| 305 |
info="See User Guide for mode definitions details."
|
| 306 |
)
|
| 307 |
|
| 308 |
+
# User Guide (美化后的手风琴)
|
|
|
|
| 309 |
with gr.Accordion("User Guide", open=True, elem_classes="main-user-guide"):
|
|
|
|
| 310 |
with gr.Accordion("Getting Started", open=False, elem_classes="clean-accordion"): gr.Markdown(USER_GUIDE_SECTIONS["getting_started"])
|
| 311 |
with gr.Accordion("Mode Definition", open=False, elem_classes="clean-accordion"): gr.Markdown(USER_GUIDE_SECTIONS["mode_definition"])
|
| 312 |
with gr.Accordion("How Clare Works", open=False, elem_classes="clean-accordion"): gr.Markdown(USER_GUIDE_SECTIONS["how_clare_works"])
|
|
|
|
| 334 |
# === [Center Main] ===
|
| 335 |
with gr.Column(scale=3):
|
| 336 |
|
| 337 |
+
# --- Upload & Memory Line Row (New Layout) ---
|
| 338 |
with gr.Row():
|
| 339 |
+
|
| 340 |
+
# [Left Group]: Upload Box + Controls (Dropdown/Button)
|
| 341 |
+
with gr.Column(scale=2): # Give this side more space (approx 66%)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
with gr.Row():
|
| 343 |
+
# Upload File Box (Larger)
|
| 344 |
+
with gr.Column(scale=3):
|
| 345 |
+
syllabus_file = gr.File(
|
| 346 |
+
file_types=[".docx", ".pdf", ".pptx"],
|
| 347 |
+
file_count="single",
|
| 348 |
+
height=150,
|
| 349 |
+
label="Upload file (.docx/.pdf/.pptx)"
|
| 350 |
+
)
|
| 351 |
+
# Controls (Dropdown + Button) stacked vertically next to file box
|
| 352 |
+
with gr.Column(scale=1):
|
| 353 |
+
doc_type = gr.Dropdown(choices=DOC_TYPES, value="Syllabus", label="", container=False)
|
| 354 |
+
# 使用 Markdown 模拟一点间距或者直接放按钮
|
| 355 |
+
docs_btn = gr.Button("📂 Loaded Docs", size="sm", variant="secondary")
|
| 356 |
|
| 357 |
+
# [Right Group]: Memory Line (Right Aligned)
|
| 358 |
+
with gr.Column(scale=1): # Less space (approx 33%)
|
| 359 |
with gr.Group(elem_classes="memory-line-box"):
|
| 360 |
gr.HTML(
|
| 361 |
f"""
|
|
|
|
| 391 |
# === [Right Sidebar] ===
|
| 392 |
with gr.Column(scale=1, min_width=180):
|
| 393 |
|
| 394 |
+
# Spacer (Push Actions down to align with Chatbot)
|
| 395 |
+
gr.HTML("<div style='height: 200px; width: 100%;'></div>")
|
| 396 |
|
| 397 |
gr.Markdown("### Actions")
|
| 398 |
|