Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
·
18ed09e
1
Parent(s):
3f59dbe
WIP: input area
Browse files
ChuanhuChatbot.py
CHANGED
|
@@ -117,37 +117,46 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
| 117 |
label="Chuanhu Chat",
|
| 118 |
elem_id="chuanhu-chatbot",
|
| 119 |
latex_delimiters=latex_delimiters_set,
|
| 120 |
-
height=700,
|
| 121 |
show_label=False,
|
| 122 |
avatar_images=[config.user_avatar, config.bot_avatar],
|
| 123 |
-
show_share_button=False
|
| 124 |
)
|
| 125 |
-
with gr.Row():
|
| 126 |
-
with gr.
|
| 127 |
-
|
| 128 |
-
elem_id="
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
)
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
with gr.Column(elem_id="toolbox-area", scale=1):
|
| 153 |
with gr.Box(elem_id="chuanhu-toolbox"): # For CSS setting, there is an extra box. Don't remove it.
|
|
|
|
| 117 |
label="Chuanhu Chat",
|
| 118 |
elem_id="chuanhu-chatbot",
|
| 119 |
latex_delimiters=latex_delimiters_set,
|
| 120 |
+
# height=700,
|
| 121 |
show_label=False,
|
| 122 |
avatar_images=[config.user_avatar, config.bot_avatar],
|
| 123 |
+
show_share_button=False,
|
| 124 |
)
|
| 125 |
+
with gr.Row(elem_id="chatbot-footer"):
|
| 126 |
+
with gr.Box(elem_id="chatbot-input-box"):
|
| 127 |
+
with gr.Row(elem_id="chatbot-input-btn-bar"):
|
| 128 |
+
gr.Button(i18n("📄 上传文档"), variant="secondary", elem_id="upload-doc-btn", elem_classes="chatbot-input-button", scale=0)
|
| 129 |
+
gr.Button(i18n("📄 xxx"), variant="secondary", elem_id="upload-index-btn", elem_classes="chatbot-input-button", scale=0)
|
| 130 |
+
gr.Button(i18n("📄 xxx"), variant="secondary", elem_id="uplasdfasdfoad-qa-btn", elem_classes="chatbot-input-button", scale=0)
|
| 131 |
+
with gr.Row(elem_id="chatbot-input-tb-row"):
|
| 132 |
+
with gr.Column(min_width=225, scale=12):
|
| 133 |
+
user_input = gr.Textbox(
|
| 134 |
+
elem_id="user-input-tb",
|
| 135 |
+
show_label=False,
|
| 136 |
+
placeholder=i18n("在这里输入"),
|
| 137 |
+
elem_classes="no-container",
|
| 138 |
+
max_lines=5,
|
| 139 |
+
# container=False
|
| 140 |
+
)
|
| 141 |
+
with gr.Column(min_width=42, scale=1, elem_id="chatbot-ctrl-btns"):
|
| 142 |
+
submitBtn = gr.Button(value="", variant="primary", elem_id="submit-btn")
|
| 143 |
+
cancelBtn = gr.Button(value="", variant="secondary", visible=False, elem_id="cancel-btn")
|
| 144 |
+
with gr.Row(elem_id="chatbot-buttons", visible=False):
|
| 145 |
+
with gr.Column(min_width=120, scale=1):
|
| 146 |
+
emptyBtn = gr.Button(
|
| 147 |
+
i18n("🧹 新的对话"), elem_id="empty-btn"
|
| 148 |
+
)
|
| 149 |
+
with gr.Column(min_width=120, scale=1):
|
| 150 |
+
retryBtn = gr.Button(i18n("🔄 重新生成"))
|
| 151 |
+
with gr.Column(min_width=120, scale=1):
|
| 152 |
+
delFirstBtn = gr.Button(i18n("🗑️ 删除最旧对话"))
|
| 153 |
+
with gr.Column(min_width=120, scale=1):
|
| 154 |
+
delLastBtn = gr.Button(i18n("🗑️ 删除最新对话"))
|
| 155 |
+
with gr.Row(visible=False) as like_dislike_area:
|
| 156 |
+
with gr.Column(min_width=20, scale=1):
|
| 157 |
+
likeBtn = gr.Button(i18n("👍"))
|
| 158 |
+
with gr.Column(min_width=20, scale=1):
|
| 159 |
+
dislikeBtn = gr.Button(i18n("👎"))
|
| 160 |
|
| 161 |
with gr.Column(elem_id="toolbox-area", scale=1):
|
| 162 |
with gr.Box(elem_id="chuanhu-toolbox"): # For CSS setting, there is an extra box. Don't remove it.
|
web_assets/javascript/ChuanhuChat.js
CHANGED
|
@@ -278,6 +278,7 @@ function setPopupBoxPosition() {
|
|
| 278 |
}
|
| 279 |
|
| 280 |
function setChatbotHeight() {
|
|
|
|
| 281 |
const screenWidth = window.innerWidth;
|
| 282 |
const statusDisplay = document.querySelector('#status-display');
|
| 283 |
const statusDisplayHeight = statusDisplay ? statusDisplay.offsetHeight : 0;
|
|
|
|
| 278 |
}
|
| 279 |
|
| 280 |
function setChatbotHeight() {
|
| 281 |
+
return;
|
| 282 |
const screenWidth = window.innerWidth;
|
| 283 |
const statusDisplay = document.querySelector('#status-display');
|
| 284 |
const statusDisplayHeight = statusDisplay ? statusDisplay.offsetHeight : 0;
|
web_assets/stylesheet/ChuanhuChat.css
CHANGED
|
@@ -10,8 +10,8 @@
|
|
| 10 |
--switch-checkbox-color-light: #e5e7eb;
|
| 11 |
--switch-checkbox-color-dark: #515151;
|
| 12 |
|
| 13 |
-
--chatbot-
|
| 14 |
-
--chatbot-
|
| 15 |
/* --menu-background-color-light: #F0F0F0;
|
| 16 |
--menu-background-color-dark: #282828; */
|
| 17 |
|
|
@@ -20,6 +20,9 @@
|
|
| 20 |
|
| 21 |
--toolbox-width: 280px;
|
| 22 |
--toolbox-background-fill: var(--background-fill-secondary);
|
|
|
|
|
|
|
|
|
|
| 23 |
}
|
| 24 |
|
| 25 |
|
|
@@ -118,9 +121,11 @@ body.popup-open {
|
|
| 118 |
color: var(--body-text-color-subdued);
|
| 119 |
}
|
| 120 |
|
| 121 |
-
|
|
|
|
|
|
|
| 122 |
#submit-btn, #cancel-btn {
|
| 123 |
-
height:
|
| 124 |
}
|
| 125 |
#submit-btn::before {
|
| 126 |
content: url("data:image/svg+xml, %3Csvg width='21px' height='20px' viewBox='0 0 21 20' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cg id='page' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cg id='send' transform='translate(0.435849, 0.088463)' fill='%23FFFFFF' fill-rule='nonzero'%3E %3Cpath d='M0.579148261,0.0428666046 C0.301105539,-0.0961547561 -0.036517765,0.122307382 0.0032026237,0.420210298 L1.4927172,18.1553639 C1.5125774,18.4334066 1.79062012,18.5922882 2.04880264,18.4929872 L8.24518329,15.8913017 L11.6412765,19.7441794 C11.8597387,19.9825018 12.2370824,19.8832008 12.3165231,19.5852979 L13.9450591,13.4882182 L19.7839562,11.0255541 C20.0619989,10.8865327 20.0818591,10.4694687 19.7839562,10.3105871 L0.579148261,0.0428666046 Z M11.6138902,17.0883151 L9.85385903,14.7195502 L0.718169621,0.618812241 L12.69945,12.9346347 L11.6138902,17.0883151 Z' id='shape'%3E%3C/path%3E %3C/g%3E %3C/g%3E %3C/svg%3E");
|
|
@@ -212,7 +217,7 @@ body.popup-open {
|
|
| 212 |
/* padding: 6px 64px; */
|
| 213 |
height: 65px;
|
| 214 |
background: var(--background-fill-primary);
|
| 215 |
-
border-bottom:
|
| 216 |
|
| 217 |
@media screen and (max-width: 639px) {
|
| 218 |
padding: 6px 16px;
|
|
@@ -257,25 +262,24 @@ body.popup-open {
|
|
| 257 |
background: var(--chatbot-background-color-dark);
|
| 258 |
}
|
| 259 |
/* #chatbot-area {
|
| 260 |
-
|
| 261 |
-
|
| 262 |
} */
|
| 263 |
#chatbot-header {
|
| 264 |
justify-content: space-between;
|
| 265 |
-
border-bottom:
|
| 266 |
height: 60px;
|
| 267 |
padding-inline: 20px;
|
| 268 |
gap: 0;
|
| 269 |
position: absolute;
|
| 270 |
top: 0;
|
|
|
|
|
|
|
| 271 |
z-index: 50;
|
| 272 |
-
background: var(--chatbot-
|
| 273 |
backdrop-filter: blur(24px);
|
| 274 |
-webkit-backdrop-filter: blur(24px);
|
| 275 |
}
|
| 276 |
-
.dark #chatbot-header {
|
| 277 |
-
background: var(--chatbot-header-background-color-dark);
|
| 278 |
-
}
|
| 279 |
|
| 280 |
#chatbot-header .gradio-dropdown {
|
| 281 |
max-width: 14em;
|
|
@@ -346,6 +350,37 @@ body.popup-open {
|
|
| 346 |
display: block;
|
| 347 |
}
|
| 348 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 349 |
/* default invisible */
|
| 350 |
#menu-area, #toolbox-area {
|
| 351 |
width: 0;
|
|
|
|
| 10 |
--switch-checkbox-color-light: #e5e7eb;
|
| 11 |
--switch-checkbox-color-dark: #515151;
|
| 12 |
|
| 13 |
+
--chatbot-blur-background-color: #F3F3F388;
|
| 14 |
+
/* --chatbot-blur-background-color-dark: #121111bb; */
|
| 15 |
/* --menu-background-color-light: #F0F0F0;
|
| 16 |
--menu-background-color-dark: #282828; */
|
| 17 |
|
|
|
|
| 20 |
|
| 21 |
--toolbox-width: 280px;
|
| 22 |
--toolbox-background-fill: var(--background-fill-secondary);
|
| 23 |
+
.dark {
|
| 24 |
+
--chatbot-blur-background-color: #12111188;
|
| 25 |
+
}
|
| 26 |
}
|
| 27 |
|
| 28 |
|
|
|
|
| 121 |
color: var(--body-text-color-subdued);
|
| 122 |
}
|
| 123 |
|
| 124 |
+
#chatbot-ctrl-btns {
|
| 125 |
+
align-self: end;
|
| 126 |
+
}
|
| 127 |
#submit-btn, #cancel-btn {
|
| 128 |
+
height: 42px !important;
|
| 129 |
}
|
| 130 |
#submit-btn::before {
|
| 131 |
content: url("data:image/svg+xml, %3Csvg width='21px' height='20px' viewBox='0 0 21 20' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cg id='page' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cg id='send' transform='translate(0.435849, 0.088463)' fill='%23FFFFFF' fill-rule='nonzero'%3E %3Cpath d='M0.579148261,0.0428666046 C0.301105539,-0.0961547561 -0.036517765,0.122307382 0.0032026237,0.420210298 L1.4927172,18.1553639 C1.5125774,18.4334066 1.79062012,18.5922882 2.04880264,18.4929872 L8.24518329,15.8913017 L11.6412765,19.7441794 C11.8597387,19.9825018 12.2370824,19.8832008 12.3165231,19.5852979 L13.9450591,13.4882182 L19.7839562,11.0255541 C20.0619989,10.8865327 20.0818591,10.4694687 19.7839562,10.3105871 L0.579148261,0.0428666046 Z M11.6138902,17.0883151 L9.85385903,14.7195502 L0.718169621,0.618812241 L12.69945,12.9346347 L11.6138902,17.0883151 Z' id='shape'%3E%3C/path%3E %3C/g%3E %3C/g%3E %3C/svg%3E");
|
|
|
|
| 217 |
/* padding: 6px 64px; */
|
| 218 |
height: 65px;
|
| 219 |
background: var(--background-fill-primary);
|
| 220 |
+
border-bottom: 1px solid var(--border-color-primary);
|
| 221 |
|
| 222 |
@media screen and (max-width: 639px) {
|
| 223 |
padding: 6px 16px;
|
|
|
|
| 262 |
background: var(--chatbot-background-color-dark);
|
| 263 |
}
|
| 264 |
/* #chatbot-area {
|
| 265 |
+
justify-content: center;
|
| 266 |
+
display: flex;
|
| 267 |
} */
|
| 268 |
#chatbot-header {
|
| 269 |
justify-content: space-between;
|
| 270 |
+
border-bottom: 0.5px solid var(--border-color-primary);
|
| 271 |
height: 60px;
|
| 272 |
padding-inline: 20px;
|
| 273 |
gap: 0;
|
| 274 |
position: absolute;
|
| 275 |
top: 0;
|
| 276 |
+
right: 4px;
|
| 277 |
+
width: calc(100% - 4px);
|
| 278 |
z-index: 50;
|
| 279 |
+
background: var(--chatbot-blur-background-color);
|
| 280 |
backdrop-filter: blur(24px);
|
| 281 |
-webkit-backdrop-filter: blur(24px);
|
| 282 |
}
|
|
|
|
|
|
|
|
|
|
| 283 |
|
| 284 |
#chatbot-header .gradio-dropdown {
|
| 285 |
max-width: 14em;
|
|
|
|
| 350 |
display: block;
|
| 351 |
}
|
| 352 |
|
| 353 |
+
#chatbot-footer {
|
| 354 |
+
position: absolute;
|
| 355 |
+
bottom: 0;
|
| 356 |
+
right: 4px;
|
| 357 |
+
width: calc(100% - 4px);
|
| 358 |
+
display: flex;
|
| 359 |
+
justify-content: center;
|
| 360 |
+
/* padding: 24px; */
|
| 361 |
+
padding: 8px 6px;
|
| 362 |
+
min-height: 120px;
|
| 363 |
+
max-height: 210px;
|
| 364 |
+
background: var(--chatbot-blur-background-color);
|
| 365 |
+
-webkit-backdrop-filter: blur(24px);
|
| 366 |
+
backdrop-filter: blur(24px);
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
#chatbot-input-box {
|
| 370 |
+
max-width: 1024px;
|
| 371 |
+
/* margin: 0 auto; */
|
| 372 |
+
gap: 20px;
|
| 373 |
+
display: flex;
|
| 374 |
+
background: none;
|
| 375 |
+
align-self: end;
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
#chatbot-input-btn-bar {
|
| 379 |
+
height: 27px;
|
| 380 |
+
overflow-y: auto;
|
| 381 |
+
flex-wrap: nowrap;
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
/* default invisible */
|
| 385 |
#menu-area, #toolbox-area {
|
| 386 |
width: 0;
|
web_assets/stylesheet/chatbot.css
CHANGED
|
@@ -55,6 +55,16 @@ hr.append-display {
|
|
| 55 |
border: none !important;
|
| 56 |
}
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
/* 亮色(默认) */
|
| 59 |
#chuanhu-chatbot {
|
| 60 |
background-color: var(--chatbot-background-color-light) !important;
|
|
@@ -107,21 +117,21 @@ hr.append-display {
|
|
| 107 |
/* 屏幕宽度大于等于500px的设备 */
|
| 108 |
/* update on 2023.4.8: 高度的细致调整已写入JavaScript */
|
| 109 |
@media screen and (min-width: 500px) {
|
| 110 |
-
#chuanhu-chatbot {
|
| 111 |
height: calc(100vh - 200px);
|
| 112 |
}
|
| 113 |
#chuanhu-chatbot>.wrapper>.wrap {
|
| 114 |
max-height: calc(100vh - 200px - var(--line-sm)*1rem - 2*var(--block-label-margin) );
|
| 115 |
-
}
|
| 116 |
}
|
| 117 |
/* 屏幕宽度小于500px的设备 */
|
| 118 |
@media screen and (max-width: 499px) {
|
| 119 |
-
#chuanhu-chatbot {
|
| 120 |
height: calc(100vh - 140px);
|
| 121 |
}
|
| 122 |
#chuanhu-chatbot>.wrapper>.wrap {
|
| 123 |
max-height: calc(100vh - 140px - var(--line-sm)*1rem - 2*var(--block-label-margin) );
|
| 124 |
-
}
|
| 125 |
[data-testid = "bot"] {
|
| 126 |
max-width: calc(100% - 84px) !important;
|
| 127 |
}
|
|
@@ -136,6 +146,10 @@ hr.append-display {
|
|
| 136 |
}
|
| 137 |
}
|
| 138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
#chuanhu-chatbot>.wrapper>.wrap {
|
| 140 |
overflow-x: hidden;
|
| 141 |
display: flex;
|
|
@@ -143,6 +157,7 @@ hr.append-display {
|
|
| 143 |
flex-direction: column;
|
| 144 |
padding-inline: 20px;
|
| 145 |
padding-top: 72px;
|
|
|
|
| 146 |
}
|
| 147 |
#chuanhu-chatbot>.wrapper>.wrap .message-wrap {
|
| 148 |
align-self: center;
|
|
|
|
| 55 |
border: none !important;
|
| 56 |
}
|
| 57 |
|
| 58 |
+
#user-input-tb {
|
| 59 |
+
padding: 0 !important;
|
| 60 |
+
border: 1px solid rgba(167, 167, 167, 0.5) !important;
|
| 61 |
+
border-radius: 21px !important;
|
| 62 |
+
}
|
| 63 |
+
#user-input-tb textarea {
|
| 64 |
+
/* max-height: 110px; */
|
| 65 |
+
background: transparent;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
/* 亮色(默认) */
|
| 69 |
#chuanhu-chatbot {
|
| 70 |
background-color: var(--chatbot-background-color-light) !important;
|
|
|
|
| 117 |
/* 屏幕宽度大于等于500px的设备 */
|
| 118 |
/* update on 2023.4.8: 高度的细致调整已写入JavaScript */
|
| 119 |
@media screen and (min-width: 500px) {
|
| 120 |
+
/* #chuanhu-chatbot {
|
| 121 |
height: calc(100vh - 200px);
|
| 122 |
}
|
| 123 |
#chuanhu-chatbot>.wrapper>.wrap {
|
| 124 |
max-height: calc(100vh - 200px - var(--line-sm)*1rem - 2*var(--block-label-margin) );
|
| 125 |
+
} */
|
| 126 |
}
|
| 127 |
/* 屏幕宽度小于500px的设备 */
|
| 128 |
@media screen and (max-width: 499px) {
|
| 129 |
+
/* #chuanhu-chatbot {
|
| 130 |
height: calc(100vh - 140px);
|
| 131 |
}
|
| 132 |
#chuanhu-chatbot>.wrapper>.wrap {
|
| 133 |
max-height: calc(100vh - 140px - var(--line-sm)*1rem - 2*var(--block-label-margin) );
|
| 134 |
+
} */
|
| 135 |
[data-testid = "bot"] {
|
| 136 |
max-width: calc(100% - 84px) !important;
|
| 137 |
}
|
|
|
|
| 146 |
}
|
| 147 |
}
|
| 148 |
|
| 149 |
+
#chuanhu-chatbot {
|
| 150 |
+
height: calc(100vh - 65px) !important;
|
| 151 |
+
border-radius: 0;
|
| 152 |
+
}
|
| 153 |
#chuanhu-chatbot>.wrapper>.wrap {
|
| 154 |
overflow-x: hidden;
|
| 155 |
display: flex;
|
|
|
|
| 157 |
flex-direction: column;
|
| 158 |
padding-inline: 20px;
|
| 159 |
padding-top: 72px;
|
| 160 |
+
padding-bottom: 220px;
|
| 161 |
}
|
| 162 |
#chuanhu-chatbot>.wrapper>.wrap .message-wrap {
|
| 163 |
align-self: center;
|
web_assets/stylesheet/override-gradio.css
CHANGED
|
@@ -75,3 +75,35 @@ input[type=range]::-webkit-slider-runnable-track {
|
|
| 75 |
border: none;
|
| 76 |
background: transparent;
|
| 77 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
border: none;
|
| 76 |
background: transparent;
|
| 77 |
}
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
#chuanhu-chatbot>.wrapper>.wrap::-webkit-scrollbar {
|
| 81 |
+
height: 1rem;
|
| 82 |
+
width: 4px;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
#chuanhu-chatbot>.wrapper>.wrap::-webkit-scrollbar-track {
|
| 86 |
+
background-color: transparent;
|
| 87 |
+
border-radius:9999px
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
#chuanhu-chatbot>.wrapper>.wrap::-webkit-scrollbar-thumb {
|
| 91 |
+
background-color: rgba(231, 231, 231, 0.8);
|
| 92 |
+
/* border-color: rgba(255, 255, 255, var(--tw-border-opacity)); */
|
| 93 |
+
border: none;
|
| 94 |
+
border-radius: 9999px;
|
| 95 |
+
/* border-width:1px */
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
#chuanhu-chatbot>.wrapper>.wrap::-webkit-scrollbar-thumb:hover {
|
| 99 |
+
--tw-bg-opacity: 1;
|
| 100 |
+
background-color:rgb(195, 195, 195);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
.dark #chuanhu-chatbot>.wrapper>.wrap::-webkit-scrollbar-thumb {
|
| 104 |
+
background-color: rgba(56, 56, 56, 0.5);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
.dark #chuanhu-chatbot>.wrapper>.wrap::-webkit-scrollbar-thumb:hover {
|
| 108 |
+
background-color: rgba(56, 56, 56, 0.8);
|
| 109 |
+
}
|