Keldos commited on
Commit
bcb6446
1 Parent(s): 03a9483

WIP: 在chatbot header中加入导出按钮

Browse files
ChuanhuChatbot.py CHANGED
@@ -113,7 +113,10 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
113
  label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False,
114
  container=False,
115
  )
116
- gr.HTML(get_html("chatbot_header_btn.html"),elem_id="chatbot-header-btn-bar")
 
 
 
117
  with gr.Row():
118
  chatbot = gr.Chatbot(
119
  label="Chuanhu Chat",
 
113
  label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False,
114
  container=False,
115
  )
116
+ gr.HTML(get_html("chatbot_header_btn.html").format(
117
+ json_label=i18n("历史记录(JSON)"),
118
+ md_label=i18n("导出为 Markdown")
119
+ ),elem_id="chatbot-header-btn-bar")
120
  with gr.Row():
121
  chatbot = gr.Chatbot(
122
  label="Chuanhu Chat",
locale/en_US.json CHANGED
@@ -35,6 +35,8 @@
35
  "对话历史记录": "Dialog History",
36
  "💾 保存对话": "💾 Save Dialog",
37
  "📝 导出为Markdown": "📝 Export as Markdown",
 
 
38
  "默认保存于history文件夹": "Default save in history folder",
39
  "下载/上传历史记录": "Download/Upload History",
40
  "高级": "Advanced",
 
35
  "对话历史记录": "Dialog History",
36
  "💾 保存对话": "💾 Save Dialog",
37
  "📝 导出为Markdown": "📝 Export as Markdown",
38
+ "历史记录(JSON)": "History file (JSON)",
39
+ "导出为 Markdown": "Export as Markdown",
40
  "默认保存于history文件夹": "Default save in history folder",
41
  "下载/上传历史记录": "Download/Upload History",
42
  "高级": "Advanced",
locale/ja_JP.json CHANGED
@@ -35,6 +35,8 @@
35
  "对话历史记录": "会話履歴",
36
  "💾 保存对话": "💾 会話を保存",
37
  "📝 导出为Markdown": "📝 Markdownでエクスポート",
 
 
38
  "默认保存于history文件夹": "デフォルトでhistoryフォルダに保存されます",
39
  "下载/上传历史记录": "履歴をダウンロード/アップロード",
40
  "高级": "Advanced",
 
35
  "对话历史记录": "会話履歴",
36
  "💾 保存对话": "💾 会話を保存",
37
  "📝 导出为Markdown": "📝 Markdownでエクスポート",
38
+ "历史记录(JSON)": "履歴ファイル(JSON)",
39
+ "导出为 Markdown": "Markdownでエクスポート",
40
  "默认保存于history文件夹": "デフォルトでhistoryフォルダに保存されます",
41
  "下载/上传历史记录": "履歴をダウンロード/アップロード",
42
  "高级": "Advanced",
locale/ko_KR.json CHANGED
@@ -35,6 +35,8 @@
35
  "对话历史记录": "대화 기록",
36
  "💾 保存对话": "💾 대화 저장",
37
  "📝 导出为Markdown": "📝 마크다운으로 내보내기",
 
 
38
  "默认保存于history文件夹": "히스토리 폴더에 기본 저장",
39
  "下载/上传历史记录": "기록 다운로드/업로드",
40
  "高级": "고급",
 
35
  "对话历史记录": "대화 기록",
36
  "💾 保存对话": "💾 대화 저장",
37
  "📝 导出为Markdown": "📝 마크다운으로 내보내기",
38
+ "历史记录(JSON)": "기록 파일 (JSON)",
39
+ "导出为 Markdown": "마크다운으로 내보내기",
40
  "默认保存于history文件夹": "히스토리 폴더에 기본 저장",
41
  "下载/上传历史记录": "기록 다운로드/업로드",
42
  "高级": "고급",
locale/ru_RU.json CHANGED
@@ -35,6 +35,8 @@
35
  "对话历史记录": "История диалога",
36
  "💾 保存对话": "💾 Сохранить диалог",
37
  "📝 导出为Markdown": "📝 Экспортировать в Markdown",
 
 
38
  "默认保存于history文件夹": "По умолчанию сохраняется в папку history",
39
  "下载/上传历史记录": "Загрузить/загрузить историю",
40
  "高级": "Расширенные настройки",
 
35
  "对话历史记录": "История диалога",
36
  "💾 保存对话": "💾 Сохранить диалог",
37
  "📝 导出为Markdown": "📝 Экспортировать в Markdown",
38
+ "历史记录(JSON)": "Файл истории (JSON)",
39
+ "导出为 Markdown": "Экспортировать в Markdown",
40
  "默认保存于history文件夹": "По умолчанию сохраняется в папку history",
41
  "下载/上传历史记录": "Загрузить/загрузить историю",
42
  "高级": "Расширенные настройки",
locale/sv-SE.json CHANGED
@@ -35,6 +35,8 @@
35
  "对话历史记录": "Dialoghistorik",
36
  "💾 保存对话": "💾 Spara Dialog",
37
  "📝 导出为Markdown": "📝 Exportera som Markdown",
 
 
38
  "默认保存于history文件夹": "Sparas som standard i mappen history",
39
  "下载/上传历史记录": "Ladda ner/ladda upp historik",
40
  "高级": "Avancerat",
 
35
  "对话历史记录": "Dialoghistorik",
36
  "💾 保存对话": "💾 Spara Dialog",
37
  "📝 导出为Markdown": "📝 Exportera som Markdown",
38
+ "历史记录(JSON)": "Historikfil (JSON)",
39
+ "导出为 Markdown": "Exportera som Markdown",
40
  "默认保存于history文件夹": "Sparas som standard i mappen history",
41
  "下载/上传历史记录": "Ladda ner/ladda upp historik",
42
  "高级": "Avancerat",
web_assets/html/chatbot_header_btn.html CHANGED
@@ -14,6 +14,25 @@
14
  </div>
15
 
16
  <div class="btn-bar-group">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  <button id="new-chat-btn" onclick="newChatClick()" class="chuanhu-ui-btn">
18
  <svg width="24px" height="24px" viewBox="0 0 41.3058 37.9805" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
19
  <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
 
14
  </div>
15
 
16
  <div class="btn-bar-group">
17
+ <div class="nav-item-dropdown">
18
+ <button id="export-chat-btn" onclick="" class="chuanhu-ui-btn dropdown-trigger">
19
+ <svg width="24px" height="24px" viewBox="0 0 16.1359 20.56475" version="1.1" xmlns="http://www.w3.org/2000/svg">
20
+ <g stroke="none" fill="currentColor" fill-opacity="0.85" fill-rule="nonzero">
21
+ <path d="M13.3438,5.76305 C15.2024,5.76305 16.1359,6.7002 16.1359,8.5309 L16.1359,17.79695 C16.1359,19.62395 15.2024,20.56475 13.3438,20.56475 L2.79211,20.56475 C0.941602,20.56475 0,19.63125 0,17.79695 L0,8.5309 C0,6.69293 0.941602,5.76305 2.79211,5.76305 L5.71,5.76275 L5.71,7.06975 L2.81555,7.06993 C1.89173222,7.06993 1.36322898,7.53591574 1.30735769,8.43213487 L1.30242,8.59475 L1.30242,17.73305 C1.30242,18.74355 1.83739,19.25425 2.81555,19.25425 L13.3204,19.25425 C14.2759,19.25425 14.8335,18.74355 14.8335,17.73305 L14.8335,8.59475 C14.8335,7.59235 14.2759,7.06993 13.3204,7.06993 L10.416,7.06975 L10.416,5.76275 L13.3438,5.76305 Z"></path>
22
+ <path d="M8.06391,13.43715 C8.41559,13.43715 8.71512,13.14575 8.71512,12.80215 L8.71512,3.14567 L8.66297,1.78664 L9.38039,2.54004 L10.8584,4.09078 C10.978,4.21852 11.1454,4.28602 11.301,4.28602 C11.6373,4.28602 11.8964,4.04309 11.8964,3.7193 C11.8964,3.53941 11.8245,3.41531 11.6967,3.29566 L8.5316,0.21586 C8.37153,0.05578 8.2357,0 8.06391,0 C7.9002,0 7.76074,0.05578 7.59621,0.21586 L4.42746,3.29566 C4.30781,3.41531 4.23586,3.53941 4.23586,3.7193 C4.23586,4.04309 4.48324,4.28602 4.82321,4.28602 C4.97883,4.28602 5.15426,4.21852 5.27028,4.09078 L6.75188,2.54004 L7.47293,1.78301 L7.42078,3.14567 L7.42078,12.80215 C7.42078,13.14575 7.72031,13.43715 8.06391,13.43715 Z"></path>
23
+ </g>
24
+ </svg>
25
+ </button>
26
+ <div class="dropdown-menu">
27
+ <div class="dropdown-menu-item">
28
+ <button onclick="jsonDownloadClick()">{json_label}</button>
29
+ </div>
30
+ <div class="dropdown-menu-item">
31
+ <button onclick="mdDownloadClick()">{md_label}</button>
32
+ </div>
33
+ </div>
34
+ </div>
35
+
36
  <button id="new-chat-btn" onclick="newChatClick()" class="chuanhu-ui-btn">
37
  <svg width="24px" height="24px" viewBox="0 0 41.3058 37.9805" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
38
  <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
web_assets/javascript/fake-gradio.js CHANGED
@@ -5,6 +5,12 @@
5
  function newChatClick() {
6
  gradioApp().querySelector('#empty-btn').click();
7
  }
 
 
 
 
 
 
8
 
9
  // index files
10
  function setUploader() {
 
5
  function newChatClick() {
6
  gradioApp().querySelector('#empty-btn').click();
7
  }
8
+ function jsonDownloadClick() {
9
+ gradioApp().querySelector('#gr-history-download-btn').click();
10
+ }
11
+ function mdDownloadClick() {
12
+ return;
13
+ }
14
 
15
  // index files
16
  function setUploader() {
web_assets/stylesheet/custom-components.css CHANGED
@@ -321,4 +321,46 @@ input:checked + .apSlider::before {
321
  .tooltip-toggle:hover::after {
322
  opacity: 1;
323
  transition: all 0.5s ease;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  }
 
321
  .tooltip-toggle:hover::after {
322
  opacity: 1;
323
  transition: all 0.5s ease;
324
+ }
325
+
326
+
327
+ .nav-item-dropdown, .dropdown-trigger {
328
+ position: relative;
329
+ }
330
+ .nav-item-dropdown:hover>.dropdown-menu {
331
+ display: block;
332
+ opacity: 1;
333
+ }
334
+ .dropdown-trigger:focus+.dropdown-menu {
335
+ display: block;
336
+ opacity: 1;
337
+ }
338
+ .dropdown-menu {
339
+ background-color: var(--chatbot-input-more-background-solid-color);
340
+ display: inline-block;
341
+ /* text-align: right; */
342
+ position: absolute;
343
+ /* top: 2.5rem; */
344
+ left: 50%;
345
+ transform: translateX(-50%);
346
+ display: none;
347
+ opacity: 0;
348
+ transition: opacity 0.5s ease;
349
+ width: auto;
350
+ border-radius: 5px;
351
+ box-shadow: var(--shadow-sm);
352
+ }
353
+
354
+ .dropdown-menu-item {
355
+ cursor: pointer;
356
+ padding: 8px 12px;
357
+ text-align: center;
358
+ white-space: nowrap;
359
+ margin: 0 !important;
360
+ }
361
+ .dropdown-menu-item button {
362
+ margin: 0 !important;
363
+ }
364
+ .dropdown-menu-item:hover {
365
+ background-color: var(--chatbot-input-more-background-mobilewidth-hover);
366
  }