Skip to content

Commit

Permalink
refactor: rebind download button
Browse files Browse the repository at this point in the history
  • Loading branch information
Keldos-Li authored and GaiZhenbiao committed Sep 19, 2024
1 parent ccc7479 commit 3d27b4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
15 changes: 4 additions & 11 deletions ChuanhuChatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ def create_new_model():
with gr.Column(scale=1):
renameHistoryBtn = gr.Button(
i18n("💾 保存对话"), elem_id="gr-history-save-btn")
exportMarkdownBtn = gr.Button(
i18n("📝 导出为 Markdown"), elem_id="gr-markdown-export-btn")
downloadHistoryJSONBtn = gr.DownloadButton(
i18n("历史记录(JSON)"), elem_id="gr-history-download-json-btn")
downloadHistoryMarkdownBtn = gr.DownloadButton(
i18n("导出为 Markdown"), elem_id="gr-history-download-md-btn")

with gr.Column(elem_id="chuanhu-menu-footer"):
with gr.Row(elem_id="chuanhu-func-nav"):
Expand All @@ -120,9 +122,6 @@ def create_new_model():
label=i18n("选择模型"), choices=[], multiselect=False, interactive=True, visible=False,
container=False,
)
# with gr.Column(min_width=150, scale=1, elem_id="chatbot-header-btn-bar"):
downloadHistoryJSONBtn = gr.DownloadButton(i18n("历史记录(JSON)"))
downloadHistoryMarkdownBtn = gr.DownloadButton(i18n("导出为 Markdown"))
gr.HTML(get_html("chatbot_header_btn.html").format(
json_label=i18n("历史记录(JSON)"),
md_label=i18n("导出为 Markdown")
Expand Down Expand Up @@ -690,12 +689,6 @@ def create_greeting(request: gr.Request):
show_progress=True,
js='(a,b,c,d)=>{return saveChatHistory(a,b,c,d);}'
)
exportMarkdownBtn.click(
export_markdown,
[current_model, saveFileName, chatbot],
[],
show_progress=True,
)
historyRefreshBtn.click(**refresh_history_args)
historyDeleteBtn.click(delete_chat_history, [current_model, historySelectList], [status_display, historySelectList, chatbot], js='(a,b,c)=>{return showConfirmationDialog(a, b, c);}').then(
reset,
Expand Down
7 changes: 2 additions & 5 deletions web_assets/javascript/fake-gradio.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ function newChatClick() {
gradioApp().querySelector('#empty-btn').click();
}
function jsonDownloadClick() {
gradioApp().querySelector('#gr-history-download-btn').click();
gradioApp().querySelector('#gr-history-download-json-btn').click();
}
function mdDownloadClick() {
gradioApp().querySelector('#gr-markdown-export-btn').click();
gradioApp().querySelector('#gr-history-mardown-download-btn').click();

// downloadHistory(username, currentChatName, ".md");
gradioApp().querySelector('#gr-history-download-md-btn').click();
}

// index files
Expand Down

0 comments on commit 3d27b4d

Please sign in to comment.