Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
•
d58672c
1
Parent(s):
6957e82
WIP: 输入区文件管理提示
Browse files
ChuanhuChatbot.py
CHANGED
@@ -129,6 +129,8 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
129 |
single_turn_label=i18n("单轮对话"),
|
130 |
websearch_label=i18n("在线搜索"),
|
131 |
upload_file_label=i18n("上传文件"),
|
|
|
|
|
132 |
))
|
133 |
with gr.Row(elem_id="chatbot-input-tb-row"):
|
134 |
with gr.Column(min_width=225, scale=12):
|
@@ -199,7 +201,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
199 |
container=False,
|
200 |
)
|
201 |
gr.Markdown("---", elem_classes="hr-line")
|
202 |
-
with gr.Accordion(label=i18n("
|
203 |
use_websearch_checkbox = gr.Checkbox(label=i18n("使用在线搜索"), value=False, elem_classes="switch-checkbox", elem_id="gr-websearch-cb", visible=False)
|
204 |
index_files = gr.Files(label=i18n("上传"), type="file", elem_id="upload-index-file")
|
205 |
two_column = gr.Checkbox(label=i18n("双栏pdf"), value=advance_docs["pdf"].get("two_column", False))
|
|
|
129 |
single_turn_label=i18n("单轮对话"),
|
130 |
websearch_label=i18n("在线搜索"),
|
131 |
upload_file_label=i18n("上传文件"),
|
132 |
+
uploaded_files_label=i18n("知识库文件"),
|
133 |
+
uploaded_files_tip=i18n("在toolbox中管理知识库文件")
|
134 |
))
|
135 |
with gr.Row(elem_id="chatbot-input-tb-row"):
|
136 |
with gr.Column(min_width=225, scale=12):
|
|
|
201 |
container=False,
|
202 |
)
|
203 |
gr.Markdown("---", elem_classes="hr-line")
|
204 |
+
with gr.Accordion(label=i18n("知识库"), open=True):
|
205 |
use_websearch_checkbox = gr.Checkbox(label=i18n("使用在线搜索"), value=False, elem_classes="switch-checkbox", elem_id="gr-websearch-cb", visible=False)
|
206 |
index_files = gr.Files(label=i18n("上传"), type="file", elem_id="upload-index-file")
|
207 |
two_column = gr.Checkbox(label=i18n("双栏pdf"), value=advance_docs["pdf"].get("two_column", False))
|
web_assets/html/chatbot_more.html
CHANGED
@@ -18,7 +18,11 @@
|
|
18 |
|
19 |
<span class="chatbot-input-more-label-group">
|
20 |
<div class="chatbot-input-more-btn last-btn">
|
21 |
-
<label>
|
|
|
|
|
|
|
|
|
22 |
<button id="upload-files-btn">
|
23 |
<span class="chatbot-input-more-span">{upload_file_label}</span>
|
24 |
<span class="chatbot-input-more-icon">
|
|
|
18 |
|
19 |
<span class="chatbot-input-more-label-group">
|
20 |
<div class="chatbot-input-more-btn last-btn">
|
21 |
+
<label class="may-disable-label">
|
22 |
+
<div id="uploaded-files-div">
|
23 |
+
<span class="chatbot-input-more-span tooltip-toggle" aria-label="{uploaded_files_tip}">{uploaded_files_label}</span>
|
24 |
+
<span class="chatbot-input-more-icon" id="uploaded-files-count"></span>
|
25 |
+
</div>
|
26 |
<button id="upload-files-btn">
|
27 |
<span class="chatbot-input-more-span">{upload_file_label}</span>
|
28 |
<span class="chatbot-input-more-icon">
|
web_assets/javascript/fake-gradio.js
CHANGED
@@ -13,10 +13,11 @@ function setUploader() {
|
|
13 |
var fileInput = null;
|
14 |
var fileCount = 0;
|
15 |
fileInput = gradioApp().querySelector("#upload-index-file table.file-preview");
|
|
|
16 |
if (fileInput) {
|
17 |
chatbotArea.classList.add('with-file');
|
18 |
fileCount = fileInput.querySelectorAll('tbody > tr.file').length;
|
19 |
-
|
20 |
} else {
|
21 |
chatbotArea.classList.remove('with-file');
|
22 |
fileCount = 0;
|
|
|
13 |
var fileInput = null;
|
14 |
var fileCount = 0;
|
15 |
fileInput = gradioApp().querySelector("#upload-index-file table.file-preview");
|
16 |
+
var fileCountSpan = gradioApp().querySelector("#uploaded-files-count");
|
17 |
if (fileInput) {
|
18 |
chatbotArea.classList.add('with-file');
|
19 |
fileCount = fileInput.querySelectorAll('tbody > tr.file').length;
|
20 |
+
fileCountSpan.innerText = fileCount;
|
21 |
} else {
|
22 |
chatbotArea.classList.remove('with-file');
|
23 |
fileCount = 0;
|
web_assets/stylesheet/ChuanhuChat.css
CHANGED
@@ -512,9 +512,39 @@ button.chatbot-input-more-btn:active .sm-round-bg {
|
|
512 |
flex-direction: row-reverse;
|
513 |
display: inline-flex;
|
514 |
}
|
515 |
-
.chatbot-
|
516 |
opacity: 0.64;
|
517 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
|
519 |
/* default invisible */
|
520 |
#menu-area, #toolbox-area {
|
|
|
512 |
flex-direction: row-reverse;
|
513 |
display: inline-flex;
|
514 |
}
|
515 |
+
.chatbot-input-more-span {
|
516 |
opacity: 0.64;
|
517 |
}
|
518 |
+
input:checked + .chatbot-input-more-span {
|
519 |
+
opacity: 1;
|
520 |
+
}
|
521 |
+
|
522 |
+
#uploaded-files-div {
|
523 |
+
display: none;
|
524 |
+
}
|
525 |
+
.with-file #uploaded-files-div {
|
526 |
+
display: flex;
|
527 |
+
justify-content: space-between;
|
528 |
+
width: 100%;
|
529 |
+
}
|
530 |
+
.with-file label.may-disable-label {
|
531 |
+
cursor: not-allowed !important;
|
532 |
+
}
|
533 |
+
.with-file #uploaded-files-div > .chatbot-input-more-span {
|
534 |
+
opacity: 1;
|
535 |
+
}
|
536 |
+
#uploaded-files-count {
|
537 |
+
background: var(--primary-600);
|
538 |
+
color: white;
|
539 |
+
width: 19px;
|
540 |
+
height: 19px;
|
541 |
+
border-radius: 50%;
|
542 |
+
margin-right: 6px;
|
543 |
+
text-align: center;
|
544 |
+
}
|
545 |
+
.with-file #upload-files-btn {
|
546 |
+
display: none;
|
547 |
+
}
|
548 |
|
549 |
/* default invisible */
|
550 |
#menu-area, #toolbox-area {
|
web_assets/stylesheet/custom-components.css
CHANGED
@@ -265,4 +265,57 @@ input:checked + .apSlider::before {
|
|
265 |
|
266 |
.hr-line hr{
|
267 |
margin: 0 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
}
|
|
|
265 |
|
266 |
.hr-line hr{
|
267 |
margin: 0 !important;
|
268 |
+
}
|
269 |
+
|
270 |
+
.tooltip-toggle {
|
271 |
+
cursor: help;
|
272 |
+
position: relative;
|
273 |
+
}
|
274 |
+
|
275 |
+
.tooltip-toggle::before {
|
276 |
+
position: absolute;
|
277 |
+
bottom: calc(100% + 12px);
|
278 |
+
left: calc(50% - 60px + 0.5rem);
|
279 |
+
background-color: #2B222A;
|
280 |
+
border-radius: 5px;
|
281 |
+
color: #fff;
|
282 |
+
content: attr(aria-label);
|
283 |
+
padding: 0.5rem;
|
284 |
+
text-transform: none;
|
285 |
+
transition: all 0.5s ease;
|
286 |
+
/* height: fit-content; */
|
287 |
+
white-space: normal;
|
288 |
+
width: 120px;
|
289 |
+
}
|
290 |
+
.tooltip-toggle::after {
|
291 |
+
position: absolute;
|
292 |
+
top: -12px;
|
293 |
+
left: 50%;
|
294 |
+
border-left: 5px solid transparent;
|
295 |
+
border-right: 5px solid transparent;
|
296 |
+
border-top: 5px solid #2B222A;
|
297 |
+
content: " ";
|
298 |
+
font-size: 0;
|
299 |
+
line-height: 0;
|
300 |
+
/* margin-left: -5px; */
|
301 |
+
width: 0;
|
302 |
+
}
|
303 |
+
|
304 |
+
|
305 |
+
.tooltip-toggle::before,
|
306 |
+
.tooltip-toggle::after {
|
307 |
+
color: #efefef;
|
308 |
+
/* font-family: monospace; */
|
309 |
+
/* font-size: 16px; */
|
310 |
+
opacity: 0;
|
311 |
+
pointer-events: none;
|
312 |
+
text-align: center;
|
313 |
+
}
|
314 |
+
|
315 |
+
.tooltip-toggle:focus::before,
|
316 |
+
.tooltip-toggle:focus::after,
|
317 |
+
.tooltip-toggle:hover::before,
|
318 |
+
.tooltip-toggle:hover::after {
|
319 |
+
opacity: 1;
|
320 |
+
transition: all 0.5s ease;
|
321 |
}
|