Spaces:
Sleeping
Sleeping
Feng Chike commited on
Commit ·
dcda85a
1
Parent(s): 05ab53e
Revert "redesign: 深色古朴风 UI,左右分栏,serif 字体,精神动力学气质"
Browse filesThis reverts commit 05ab53eadf8c4b653e2e2f548af59d1477aa39dd.
main.py
CHANGED
|
@@ -250,331 +250,34 @@ def download_all_sessions():
|
|
| 250 |
return [str(f) for f in files]
|
| 251 |
|
| 252 |
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
}
|
| 271 |
-
#app-header h1 {
|
| 272 |
-
font-size: 1.2rem;
|
| 273 |
-
font-weight: normal;
|
| 274 |
-
letter-spacing: 0.4em;
|
| 275 |
-
color: #c9a84c;
|
| 276 |
-
text-transform: uppercase;
|
| 277 |
-
margin: 0;
|
| 278 |
-
}
|
| 279 |
-
#app-header p {
|
| 280 |
-
font-size: 0.72rem;
|
| 281 |
-
color: #5a5044;
|
| 282 |
-
letter-spacing: 0.12em;
|
| 283 |
-
margin: 0;
|
| 284 |
-
font-style: italic;
|
| 285 |
-
}
|
| 286 |
-
|
| 287 |
-
/* ── 主布局 ── */
|
| 288 |
-
#main-row { gap: 0 !important; min-height: 640px; }
|
| 289 |
-
#chat-col { border-right: 1px solid #1e1810; }
|
| 290 |
-
#monitor-col { background: #09080700; }
|
| 291 |
-
|
| 292 |
-
/* ── 控制栏 ── */
|
| 293 |
-
#ctrl-row {
|
| 294 |
-
padding: 0.7rem 1.4rem;
|
| 295 |
-
border-bottom: 1px solid #1a150f;
|
| 296 |
-
gap: 0.5rem !important;
|
| 297 |
-
background: #09080700;
|
| 298 |
-
}
|
| 299 |
-
#btn-start, #btn-end {
|
| 300 |
-
background: transparent !important;
|
| 301 |
-
border: 1px solid #2a221a !important;
|
| 302 |
-
border-radius: 0 !important;
|
| 303 |
-
color: #5a5044 !important;
|
| 304 |
-
font-family: 'Georgia', serif !important;
|
| 305 |
-
font-size: 0.7rem !important;
|
| 306 |
-
letter-spacing: 0.15em;
|
| 307 |
-
padding: 0.35rem 1rem !important;
|
| 308 |
-
box-shadow: none !important;
|
| 309 |
-
transition: border-color 0.2s, color 0.2s;
|
| 310 |
-
}
|
| 311 |
-
#btn-start:hover { border-color: #c9a84c !important; color: #c9a84c !important; }
|
| 312 |
-
#btn-end:hover { border-color: #6b1a1a !important; color: #9b3a3a !important; }
|
| 313 |
-
|
| 314 |
-
/* ── 聊天框 ── */
|
| 315 |
-
#chatbox {
|
| 316 |
-
background: #0e0c0a !important;
|
| 317 |
-
border: none !important;
|
| 318 |
-
border-radius: 0 !important;
|
| 319 |
-
}
|
| 320 |
-
/* 消息容器 */
|
| 321 |
-
#chatbox .bubble-wrap { padding: 1rem 1.4rem; }
|
| 322 |
-
/* 用户 */
|
| 323 |
-
#chatbox .user .message {
|
| 324 |
-
background: #171209 !important;
|
| 325 |
-
border: none !important;
|
| 326 |
-
border-left: 2px solid #6b1a1a !important;
|
| 327 |
-
border-radius: 0 !important;
|
| 328 |
-
color: #d8cfc0 !important;
|
| 329 |
-
font-size: 0.88rem;
|
| 330 |
-
line-height: 1.8;
|
| 331 |
-
padding: 0.6rem 1rem !important;
|
| 332 |
-
margin-left: 2rem !important;
|
| 333 |
-
box-shadow: none !important;
|
| 334 |
-
}
|
| 335 |
-
/* 助手 */
|
| 336 |
-
#chatbox .bot .message {
|
| 337 |
-
background: #0b0906 !important;
|
| 338 |
-
border: none !important;
|
| 339 |
-
border-left: 2px solid #c9a84c !important;
|
| 340 |
-
border-radius: 0 !important;
|
| 341 |
-
color: #b8af9f !important;
|
| 342 |
-
font-size: 0.88rem;
|
| 343 |
-
line-height: 2;
|
| 344 |
-
padding: 0.6rem 1rem !important;
|
| 345 |
-
margin-right: 2rem !important;
|
| 346 |
-
font-style: italic;
|
| 347 |
-
box-shadow: none !important;
|
| 348 |
-
}
|
| 349 |
-
/* 隐藏头像 */
|
| 350 |
-
#chatbox .avatar-container { display: none !important; }
|
| 351 |
-
|
| 352 |
-
/* ── 输入行 ── */
|
| 353 |
-
#input-row {
|
| 354 |
-
padding: 0.8rem 1.4rem;
|
| 355 |
-
border-top: 1px solid #1a150f;
|
| 356 |
-
gap: 0.6rem !important;
|
| 357 |
-
background: #0b0906;
|
| 358 |
-
align-items: flex-end !important;
|
| 359 |
-
}
|
| 360 |
-
#user-input { border: none !important; background: transparent !important; }
|
| 361 |
-
#user-input label { display: none !important; }
|
| 362 |
-
#user-input textarea {
|
| 363 |
-
background: transparent !important;
|
| 364 |
-
border: none !important;
|
| 365 |
-
border-bottom: 1px solid #2a221a !important;
|
| 366 |
-
border-radius: 0 !important;
|
| 367 |
-
color: #d4cbbf !important;
|
| 368 |
-
font-family: 'Georgia', serif !important;
|
| 369 |
-
font-size: 0.88rem;
|
| 370 |
-
padding: 0.4rem 0 !important;
|
| 371 |
-
box-shadow: none !important;
|
| 372 |
-
resize: none;
|
| 373 |
-
}
|
| 374 |
-
#user-input textarea:focus {
|
| 375 |
-
border-bottom-color: #c9a84c !important;
|
| 376 |
-
box-shadow: none !important;
|
| 377 |
-
outline: none !important;
|
| 378 |
-
}
|
| 379 |
-
#user-input textarea::placeholder { color: #3a3028 !important; }
|
| 380 |
-
#btn-send {
|
| 381 |
-
background: transparent !important;
|
| 382 |
-
border: 1px solid #2a221a !important;
|
| 383 |
-
border-radius: 0 !important;
|
| 384 |
-
color: #5a5044 !important;
|
| 385 |
-
font-family: 'Georgia', serif !important;
|
| 386 |
-
font-size: 0.7rem !important;
|
| 387 |
-
letter-spacing: 0.15em;
|
| 388 |
-
padding: 0.35rem 1rem !important;
|
| 389 |
-
box-shadow: none !important;
|
| 390 |
-
min-width: 56px;
|
| 391 |
-
transition: border-color 0.2s, color 0.2s;
|
| 392 |
-
}
|
| 393 |
-
#btn-send:hover { border-color: #c9a84c !important; color: #c9a84c !important; }
|
| 394 |
-
|
| 395 |
-
/* ── 右侧监控面板 ── */
|
| 396 |
-
#monitor-panel {
|
| 397 |
-
padding: 1.2rem 1.1rem;
|
| 398 |
-
height: 100%;
|
| 399 |
-
overflow-y: auto;
|
| 400 |
-
border-left: 1px solid #1e1810;
|
| 401 |
-
}
|
| 402 |
-
#monitor-panel .prose { font-family: 'Georgia', serif !important; }
|
| 403 |
-
#monitor-panel .prose h3 {
|
| 404 |
-
font-size: 0.6rem !important;
|
| 405 |
-
font-weight: normal;
|
| 406 |
-
letter-spacing: 0.4em;
|
| 407 |
-
color: #c9a84c !important;
|
| 408 |
-
text-transform: uppercase;
|
| 409 |
-
border-bottom: 1px solid #1e1810;
|
| 410 |
-
padding-bottom: 0.5rem;
|
| 411 |
-
margin-bottom: 1rem;
|
| 412 |
-
}
|
| 413 |
-
#monitor-panel .prose h4 {
|
| 414 |
-
font-size: 0.6rem !important;
|
| 415 |
-
font-weight: normal;
|
| 416 |
-
letter-spacing: 0.25em;
|
| 417 |
-
color: #6b1a1a !important;
|
| 418 |
-
text-transform: uppercase;
|
| 419 |
-
margin: 1.2rem 0 0.5rem;
|
| 420 |
-
}
|
| 421 |
-
#monitor-panel .prose table {
|
| 422 |
-
width: 100%;
|
| 423 |
-
border-collapse: collapse;
|
| 424 |
-
font-size: 0.74rem;
|
| 425 |
-
}
|
| 426 |
-
#monitor-panel .prose td {
|
| 427 |
-
padding: 0.22rem 0.3rem;
|
| 428 |
-
border-bottom: 1px solid #161210;
|
| 429 |
-
vertical-align: top;
|
| 430 |
-
color: #7a7060;
|
| 431 |
-
}
|
| 432 |
-
#monitor-panel .prose td:first-child {
|
| 433 |
-
color: #4a4038;
|
| 434 |
-
white-space: nowrap;
|
| 435 |
-
padding-right: 0.6rem;
|
| 436 |
-
width: 40%;
|
| 437 |
-
}
|
| 438 |
-
#monitor-panel .prose td strong { color: #9a9080 !important; }
|
| 439 |
-
#monitor-panel .prose blockquote {
|
| 440 |
-
border-left: 2px solid #2a221a;
|
| 441 |
-
margin: 0.6rem 0;
|
| 442 |
-
padding: 0.4rem 0.7rem;
|
| 443 |
-
color: #7a7060 !important;
|
| 444 |
-
font-style: italic;
|
| 445 |
-
font-size: 0.76rem;
|
| 446 |
-
}
|
| 447 |
-
#monitor-panel .prose code {
|
| 448 |
-
background: #151210 !important;
|
| 449 |
-
color: #b09040 !important;
|
| 450 |
-
font-family: 'Courier New', monospace !important;
|
| 451 |
-
font-size: 0.7rem;
|
| 452 |
-
padding: 0.05rem 0.3rem;
|
| 453 |
-
border-radius: 0;
|
| 454 |
-
}
|
| 455 |
-
#monitor-panel .prose hr {
|
| 456 |
-
border: none;
|
| 457 |
-
border-top: 1px solid #1a1510;
|
| 458 |
-
margin: 0.9rem 0;
|
| 459 |
-
}
|
| 460 |
-
#monitor-panel .prose strong { color: #9a9080 !important; }
|
| 461 |
-
#monitor-panel .prose details summary {
|
| 462 |
-
color: #4a4038;
|
| 463 |
-
cursor: pointer;
|
| 464 |
-
font-size: 0.68rem;
|
| 465 |
-
letter-spacing: 0.08em;
|
| 466 |
-
}
|
| 467 |
-
#monitor-panel .prose em { color: #5a5044; }
|
| 468 |
-
|
| 469 |
-
/* ── 研究者折叠面板 ── */
|
| 470 |
-
#researcher-accordion {
|
| 471 |
-
background: transparent !important;
|
| 472 |
-
border: none !important;
|
| 473 |
-
border-top: 1px solid #1a150f !important;
|
| 474 |
-
border-radius: 0 !important;
|
| 475 |
-
margin-top: 0 !important;
|
| 476 |
-
}
|
| 477 |
-
#researcher-accordion > .label-wrap {
|
| 478 |
-
padding: 0.6rem 1.4rem !important;
|
| 479 |
-
background: transparent !important;
|
| 480 |
-
}
|
| 481 |
-
#researcher-accordion > .label-wrap span {
|
| 482 |
-
font-family: 'Georgia', serif !important;
|
| 483 |
-
font-size: 0.65rem !important;
|
| 484 |
-
letter-spacing: 0.3em;
|
| 485 |
-
color: #3a3028 !important;
|
| 486 |
-
text-transform: uppercase;
|
| 487 |
-
}
|
| 488 |
-
#researcher-accordion .icon { color: #3a3028 !important; }
|
| 489 |
-
#log-display label { display: none !important; }
|
| 490 |
-
#log-display textarea {
|
| 491 |
-
background: #080706 !important;
|
| 492 |
-
border: 1px solid #1a150f !important;
|
| 493 |
-
border-radius: 0 !important;
|
| 494 |
-
color: #4a4038 !important;
|
| 495 |
-
font-family: 'Courier New', monospace !important;
|
| 496 |
-
font-size: 0.7rem !important;
|
| 497 |
-
line-height: 1.6;
|
| 498 |
-
}
|
| 499 |
-
"""
|
| 500 |
-
|
| 501 |
-
INIT_STATUS = """\
|
| 502 |
-
### ◈ Session Monitor
|
| 503 |
-
|
| 504 |
-
*Psychoanalytic Depth Tracking*
|
| 505 |
-
|
| 506 |
-
---
|
| 507 |
-
|
| 508 |
-
> 等待会话开始…
|
| 509 |
-
|
| 510 |
-
"""
|
| 511 |
-
|
| 512 |
-
with gr.Blocks(title="Freud · Zero", css=CSS) as app:
|
| 513 |
-
|
| 514 |
-
# ── 标题 ──
|
| 515 |
-
gr.HTML("""
|
| 516 |
-
<div id="app-header">
|
| 517 |
-
<h1>Freud · Zero</h1>
|
| 518 |
-
<p>Psychodynamic Counselling System · 精神动力学取向 · 自我揭露深度追踪</p>
|
| 519 |
-
</div>
|
| 520 |
-
""")
|
| 521 |
-
|
| 522 |
-
# ── 主布局:左右分栏 ──
|
| 523 |
-
with gr.Row(elem_id="main-row"):
|
| 524 |
-
|
| 525 |
-
# 左:聊天区
|
| 526 |
-
with gr.Column(scale=3, elem_id="chat-col"):
|
| 527 |
-
|
| 528 |
-
with gr.Row(elem_id="ctrl-row"):
|
| 529 |
-
btn_start = gr.Button("⬡ 新会话", elem_id="btn-start", scale=0)
|
| 530 |
-
btn_end = gr.Button("○ 结束", elem_id="btn-end", scale=0)
|
| 531 |
-
|
| 532 |
-
chatbot = gr.Chatbot(
|
| 533 |
-
label="", height=520,
|
| 534 |
-
type="messages",
|
| 535 |
-
elem_id="chatbox",
|
| 536 |
-
show_label=False,
|
| 537 |
-
avatar_images=(None, None),
|
| 538 |
-
)
|
| 539 |
-
|
| 540 |
-
with gr.Row(elem_id="input-row"):
|
| 541 |
-
user_input = gr.Textbox(
|
| 542 |
-
placeholder="说你想说的……",
|
| 543 |
-
show_label=False,
|
| 544 |
-
lines=1,
|
| 545 |
-
scale=6,
|
| 546 |
-
elem_id="user-input",
|
| 547 |
-
)
|
| 548 |
-
btn_send = gr.Button("发送", scale=1, elem_id="btn-send")
|
| 549 |
-
|
| 550 |
-
# 右:监控面板
|
| 551 |
-
with gr.Column(scale=2, elem_id="monitor-col"):
|
| 552 |
-
status_output = gr.Markdown(
|
| 553 |
-
value=INIT_STATUS,
|
| 554 |
-
elem_id="monitor-panel",
|
| 555 |
-
)
|
| 556 |
-
|
| 557 |
-
# ── 研究者面板 ──
|
| 558 |
-
with gr.Accordion("◈ 研究者面板", open=False, elem_id="researcher-accordion"):
|
| 559 |
with gr.Row():
|
| 560 |
-
btn_view
|
| 561 |
-
btn_download = gr.Button("下载日志"
|
| 562 |
-
log_display = gr.Textbox(label="", lines=20, interactive=False
|
| 563 |
-
file_output = gr.File(label="")
|
| 564 |
|
| 565 |
-
#
|
| 566 |
btn_start.click(start_session, outputs=[chatbot, status_output])
|
| 567 |
btn_end.click(end_session, outputs=[status_output])
|
| 568 |
-
btn_send.click(
|
| 569 |
-
|
| 570 |
-
inputs=[user_input, chatbot],
|
| 571 |
-
outputs=[chatbot, user_input, status_output, log_display],
|
| 572 |
-
)
|
| 573 |
-
user_input.submit(
|
| 574 |
-
chat,
|
| 575 |
-
inputs=[user_input, chatbot],
|
| 576 |
-
outputs=[chatbot, user_input, status_output, log_display],
|
| 577 |
-
)
|
| 578 |
btn_view.click(view_sessions, outputs=[log_display])
|
| 579 |
btn_download.click(download_all_sessions, outputs=[file_output])
|
| 580 |
|
|
|
|
| 250 |
return [str(f) for f in files]
|
| 251 |
|
| 252 |
|
| 253 |
+
with gr.Blocks(title="Freud-Zero MVP") as app:
|
| 254 |
+
gr.Markdown("# Freud-Zero MVP")
|
| 255 |
+
gr.Markdown("精神动力学取向回应性咨询师 · 自我揭露深度追踪")
|
| 256 |
+
|
| 257 |
+
with gr.Row():
|
| 258 |
+
btn_start = gr.Button("开始新会话", variant="primary")
|
| 259 |
+
btn_end = gr.Button("结束会话", variant="stop")
|
| 260 |
+
|
| 261 |
+
chatbot = gr.Chatbot(label="对话", height=480, type="messages")
|
| 262 |
+
|
| 263 |
+
with gr.Row():
|
| 264 |
+
user_input = gr.Textbox(placeholder="说你想说的……", show_label=False, scale=4)
|
| 265 |
+
btn_send = gr.Button("发送", scale=1)
|
| 266 |
+
|
| 267 |
+
status_output = gr.Markdown(value="### 🧠 SESSION MONITOR\n\n> 等待开始会话…")
|
| 268 |
+
|
| 269 |
+
with gr.Accordion("研究者面板", open=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
with gr.Row():
|
| 271 |
+
btn_view = gr.Button("查看所有会话记录")
|
| 272 |
+
btn_download = gr.Button("下载日志文件")
|
| 273 |
+
log_display = gr.Textbox(label="会话日志", lines=20, interactive=False)
|
| 274 |
+
file_output = gr.File(label="日志文件")
|
| 275 |
|
| 276 |
+
# 绑定事件
|
| 277 |
btn_start.click(start_session, outputs=[chatbot, status_output])
|
| 278 |
btn_end.click(end_session, outputs=[status_output])
|
| 279 |
+
btn_send.click(chat, inputs=[user_input, chatbot], outputs=[chatbot, user_input, status_output, log_display])
|
| 280 |
+
user_input.submit(chat, inputs=[user_input, chatbot], outputs=[chatbot, user_input, status_output, log_display])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
btn_view.click(view_sessions, outputs=[log_display])
|
| 282 |
btn_download.click(download_all_sessions, outputs=[file_output])
|
| 283 |
|