Spaces:
Sleeping
Sleeping
Update app_gradio_messenger.py
Browse files- app_gradio_messenger.py +54 -40
app_gradio_messenger.py
CHANGED
|
@@ -73,6 +73,10 @@ CUSTOM_CSS = """
|
|
| 73 |
--user-bubble: #ffe6c7;
|
| 74 |
--assistant-bubble: #fff7f0;
|
| 75 |
--assistant-text: #1f1820;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
}
|
| 77 |
|
| 78 |
body, .gradio-container {
|
|
@@ -88,21 +92,14 @@ body, .gradio-container {
|
|
| 88 |
}
|
| 89 |
|
| 90 |
.messenger-shell {
|
| 91 |
-
|
| 92 |
-
min-height: 0;
|
| 93 |
-
max-height: calc(100vh - 36px);
|
| 94 |
-
overflow: hidden;
|
| 95 |
}
|
| 96 |
|
| 97 |
.messenger-layout {
|
| 98 |
-
display:
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
min-height: 0;
|
| 103 |
-
max-height: calc(100vh - 36px);
|
| 104 |
-
overflow: hidden;
|
| 105 |
-
align-items: stretch;
|
| 106 |
}
|
| 107 |
|
| 108 |
.messenger-panel {
|
|
@@ -112,14 +109,17 @@ body, .gradio-container {
|
|
| 112 |
box-shadow: var(--messenger-shadow);
|
| 113 |
backdrop-filter: blur(12px);
|
| 114 |
overflow: hidden;
|
|
|
|
|
|
|
|
|
|
| 115 |
}
|
| 116 |
|
| 117 |
.sidebar {
|
| 118 |
display: flex;
|
| 119 |
flex-direction: column;
|
| 120 |
min-height: 0;
|
| 121 |
-
|
| 122 |
-
|
| 123 |
}
|
| 124 |
|
| 125 |
.sidebar-head {
|
|
@@ -145,6 +145,7 @@ body, .gradio-container {
|
|
| 145 |
flex-direction: column;
|
| 146 |
gap: 10px;
|
| 147 |
min-height: 0;
|
|
|
|
| 148 |
overflow-y: auto;
|
| 149 |
}
|
| 150 |
|
|
@@ -191,9 +192,9 @@ body, .gradio-container {
|
|
| 191 |
.chat-stage {
|
| 192 |
display: flex;
|
| 193 |
flex-direction: column;
|
| 194 |
-
height:
|
| 195 |
min-height: 0;
|
| 196 |
-
max-height:
|
| 197 |
overflow: hidden;
|
| 198 |
}
|
| 199 |
|
|
@@ -205,12 +206,16 @@ body, .gradio-container {
|
|
| 205 |
|
| 206 |
.chat-head-wrap {
|
| 207 |
flex: 0 0 auto;
|
|
|
|
|
|
|
|
|
|
| 208 |
}
|
| 209 |
|
| 210 |
.chat-history-wrap {
|
| 211 |
-
flex:
|
| 212 |
-
|
| 213 |
-
height:
|
|
|
|
| 214 |
overflow: hidden;
|
| 215 |
display: flex;
|
| 216 |
flex-direction: column;
|
|
@@ -218,13 +223,15 @@ body, .gradio-container {
|
|
| 218 |
|
| 219 |
.chat-history-wrap > *,
|
| 220 |
.chat-history-wrap > * > * {
|
| 221 |
-
height:
|
| 222 |
-
min-height:
|
| 223 |
-
max-height:
|
| 224 |
overflow: hidden !important;
|
| 225 |
}
|
| 226 |
|
| 227 |
.chat-head {
|
|
|
|
|
|
|
| 228 |
padding: 18px 20px 14px;
|
| 229 |
border-bottom: 1px solid var(--messenger-line);
|
| 230 |
display: flex;
|
|
@@ -353,6 +360,10 @@ body, .gradio-container {
|
|
| 353 |
|
| 354 |
.chat-compose {
|
| 355 |
flex: 0 0 auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 356 |
padding: 14px 16px 16px;
|
| 357 |
border-top: 1px solid var(--messenger-line);
|
| 358 |
}
|
|
@@ -403,35 +414,38 @@ body, .gradio-container {
|
|
| 403 |
}
|
| 404 |
|
| 405 |
@media (max-width: 900px) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
.messenger-layout {
|
| 407 |
-
|
| 408 |
}
|
| 409 |
|
| 410 |
.sidebar {
|
| 411 |
-
|
| 412 |
-
height:
|
| 413 |
-
max-height:
|
| 414 |
-
overflow: hidden;
|
| 415 |
}
|
| 416 |
|
| 417 |
.chat-stage {
|
| 418 |
-
height:
|
| 419 |
-
|
| 420 |
-
max-height: 70vh;
|
| 421 |
}
|
| 422 |
|
| 423 |
.chat-history-wrap {
|
| 424 |
-
|
| 425 |
-
min-height:
|
| 426 |
-
height:
|
| 427 |
-
max-height: 320px;
|
| 428 |
}
|
| 429 |
|
| 430 |
.chat-history-wrap > *,
|
| 431 |
.chat-history-wrap > * > * {
|
| 432 |
-
height:
|
| 433 |
-
min-height:
|
| 434 |
-
max-height:
|
| 435 |
}
|
| 436 |
}
|
| 437 |
""".strip()
|
|
@@ -581,16 +595,16 @@ async def respond(
|
|
| 581 |
)
|
| 582 |
|
| 583 |
|
| 584 |
-
with gr.Blocks(title="Megumin Messenger"
|
| 585 |
history_state = gr.State(value=initial_history())
|
| 586 |
session_state = gr.State(value=None)
|
| 587 |
|
| 588 |
with gr.Column(elem_classes=["messenger-shell"]):
|
| 589 |
with gr.Row(elem_classes=["messenger-layout"]):
|
| 590 |
-
with gr.Column(elem_classes=["messenger-panel", "sidebar"]):
|
| 591 |
sidebar_html = gr.HTML(render_sidebar(initial_history()))
|
| 592 |
|
| 593 |
-
with gr.Column(elem_classes=["messenger-panel", "chat-stage"]):
|
| 594 |
gr.HTML(
|
| 595 |
f"""
|
| 596 |
<div class="chat-head">
|
|
|
|
| 73 |
--user-bubble: #ffe6c7;
|
| 74 |
--assistant-bubble: #fff7f0;
|
| 75 |
--assistant-text: #1f1820;
|
| 76 |
+
--messenger-panel-height: 820px;
|
| 77 |
+
--messenger-head-height: 96px;
|
| 78 |
+
--messenger-compose-height: 176px;
|
| 79 |
+
--messenger-gap: 18px;
|
| 80 |
}
|
| 81 |
|
| 82 |
body, .gradio-container {
|
|
|
|
| 92 |
}
|
| 93 |
|
| 94 |
.messenger-shell {
|
| 95 |
+
width: 100%;
|
|
|
|
|
|
|
|
|
|
| 96 |
}
|
| 97 |
|
| 98 |
.messenger-layout {
|
| 99 |
+
display: flex !important;
|
| 100 |
+
flex-wrap: nowrap !important;
|
| 101 |
+
align-items: flex-start !important;
|
| 102 |
+
gap: var(--messenger-gap);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
}
|
| 104 |
|
| 105 |
.messenger-panel {
|
|
|
|
| 109 |
box-shadow: var(--messenger-shadow);
|
| 110 |
backdrop-filter: blur(12px);
|
| 111 |
overflow: hidden;
|
| 112 |
+
height: var(--messenger-panel-height);
|
| 113 |
+
min-height: var(--messenger-panel-height);
|
| 114 |
+
max-height: var(--messenger-panel-height);
|
| 115 |
}
|
| 116 |
|
| 117 |
.sidebar {
|
| 118 |
display: flex;
|
| 119 |
flex-direction: column;
|
| 120 |
min-height: 0;
|
| 121 |
+
height: var(--messenger-panel-height);
|
| 122 |
+
max-height: var(--messenger-panel-height);
|
| 123 |
}
|
| 124 |
|
| 125 |
.sidebar-head {
|
|
|
|
| 145 |
flex-direction: column;
|
| 146 |
gap: 10px;
|
| 147 |
min-height: 0;
|
| 148 |
+
flex: 1 1 auto;
|
| 149 |
overflow-y: auto;
|
| 150 |
}
|
| 151 |
|
|
|
|
| 192 |
.chat-stage {
|
| 193 |
display: flex;
|
| 194 |
flex-direction: column;
|
| 195 |
+
height: var(--messenger-panel-height);
|
| 196 |
min-height: 0;
|
| 197 |
+
max-height: var(--messenger-panel-height);
|
| 198 |
overflow: hidden;
|
| 199 |
}
|
| 200 |
|
|
|
|
| 206 |
|
| 207 |
.chat-head-wrap {
|
| 208 |
flex: 0 0 auto;
|
| 209 |
+
height: var(--messenger-head-height);
|
| 210 |
+
min-height: var(--messenger-head-height);
|
| 211 |
+
max-height: var(--messenger-head-height);
|
| 212 |
}
|
| 213 |
|
| 214 |
.chat-history-wrap {
|
| 215 |
+
flex: 0 0 auto;
|
| 216 |
+
height: calc(var(--messenger-panel-height) - var(--messenger-head-height) - var(--messenger-compose-height));
|
| 217 |
+
min-height: calc(var(--messenger-panel-height) - var(--messenger-head-height) - var(--messenger-compose-height));
|
| 218 |
+
max-height: calc(var(--messenger-panel-height) - var(--messenger-head-height) - var(--messenger-compose-height));
|
| 219 |
overflow: hidden;
|
| 220 |
display: flex;
|
| 221 |
flex-direction: column;
|
|
|
|
| 223 |
|
| 224 |
.chat-history-wrap > *,
|
| 225 |
.chat-history-wrap > * > * {
|
| 226 |
+
height: 100% !important;
|
| 227 |
+
min-height: 0 !important;
|
| 228 |
+
max-height: 100% !important;
|
| 229 |
overflow: hidden !important;
|
| 230 |
}
|
| 231 |
|
| 232 |
.chat-head {
|
| 233 |
+
height: var(--messenger-head-height);
|
| 234 |
+
box-sizing: border-box;
|
| 235 |
padding: 18px 20px 14px;
|
| 236 |
border-bottom: 1px solid var(--messenger-line);
|
| 237 |
display: flex;
|
|
|
|
| 360 |
|
| 361 |
.chat-compose {
|
| 362 |
flex: 0 0 auto;
|
| 363 |
+
height: var(--messenger-compose-height);
|
| 364 |
+
min-height: var(--messenger-compose-height);
|
| 365 |
+
max-height: var(--messenger-compose-height);
|
| 366 |
+
box-sizing: border-box;
|
| 367 |
padding: 14px 16px 16px;
|
| 368 |
border-top: 1px solid var(--messenger-line);
|
| 369 |
}
|
|
|
|
| 414 |
}
|
| 415 |
|
| 416 |
@media (max-width: 900px) {
|
| 417 |
+
:root {
|
| 418 |
+
--messenger-panel-height: 680px;
|
| 419 |
+
--messenger-head-height: 92px;
|
| 420 |
+
--messenger-compose-height: 172px;
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
.messenger-layout {
|
| 424 |
+
flex-direction: column !important;
|
| 425 |
}
|
| 426 |
|
| 427 |
.sidebar {
|
| 428 |
+
height: 180px;
|
| 429 |
+
min-height: 180px;
|
| 430 |
+
max-height: 180px;
|
|
|
|
| 431 |
}
|
| 432 |
|
| 433 |
.chat-stage {
|
| 434 |
+
height: var(--messenger-panel-height);
|
| 435 |
+
max-height: var(--messenger-panel-height);
|
|
|
|
| 436 |
}
|
| 437 |
|
| 438 |
.chat-history-wrap {
|
| 439 |
+
height: calc(var(--messenger-panel-height) - var(--messenger-head-height) - var(--messenger-compose-height));
|
| 440 |
+
min-height: calc(var(--messenger-panel-height) - var(--messenger-head-height) - var(--messenger-compose-height));
|
| 441 |
+
max-height: calc(var(--messenger-panel-height) - var(--messenger-head-height) - var(--messenger-compose-height));
|
|
|
|
| 442 |
}
|
| 443 |
|
| 444 |
.chat-history-wrap > *,
|
| 445 |
.chat-history-wrap > * > * {
|
| 446 |
+
height: 100% !important;
|
| 447 |
+
min-height: 0 !important;
|
| 448 |
+
max-height: 100% !important;
|
| 449 |
}
|
| 450 |
}
|
| 451 |
""".strip()
|
|
|
|
| 595 |
)
|
| 596 |
|
| 597 |
|
| 598 |
+
with gr.Blocks(title="Megumin Messenger") as demo:
|
| 599 |
history_state = gr.State(value=initial_history())
|
| 600 |
session_state = gr.State(value=None)
|
| 601 |
|
| 602 |
with gr.Column(elem_classes=["messenger-shell"]):
|
| 603 |
with gr.Row(elem_classes=["messenger-layout"]):
|
| 604 |
+
with gr.Column(scale=3, min_width=320, elem_classes=["messenger-panel", "sidebar"]):
|
| 605 |
sidebar_html = gr.HTML(render_sidebar(initial_history()))
|
| 606 |
|
| 607 |
+
with gr.Column(scale=7, min_width=680, elem_classes=["messenger-panel", "chat-stage"]):
|
| 608 |
gr.HTML(
|
| 609 |
f"""
|
| 610 |
<div class="chat-head">
|