Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
•
fce5dd0
1
Parent(s):
43981f0
feat: 加入删除确认
Browse files- ChuanhuChatbot.py +13 -2
- modules/models/base_model.py +2 -0
ChuanhuChatbot.py
CHANGED
@@ -326,6 +326,10 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
|
|
326 |
outputs=[saveFileName, systemPromptTxt, chatbot]
|
327 |
)
|
328 |
|
|
|
|
|
|
|
|
|
329 |
|
330 |
# Chatbot
|
331 |
cancelBtn.click(interrupt, [current_model], [])
|
@@ -428,8 +432,15 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
|
|
428 |
downloadFile,
|
429 |
show_progress=True,
|
430 |
)
|
431 |
-
historyRefreshBtn.click(
|
432 |
-
historyDeleteBtn.click(delete_chat_history, [current_model, historyFileSelectDropdown, user_name], [status_display, historyFileSelectDropdown])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
433 |
historyFileSelectDropdown.change(**load_history_from_file_args)
|
434 |
downloadFile.change(upload_chat_history, [current_model, downloadFile, user_name], [saveFileName, systemPromptTxt, chatbot])
|
435 |
|
|
|
326 |
outputs=[saveFileName, systemPromptTxt, chatbot]
|
327 |
)
|
328 |
|
329 |
+
refresh_history_args = dict(
|
330 |
+
fn=get_history_names, inputs=[gr.State(False), user_name], outputs=[historyFileSelectDropdown]
|
331 |
+
)
|
332 |
+
|
333 |
|
334 |
# Chatbot
|
335 |
cancelBtn.click(interrupt, [current_model], [])
|
|
|
432 |
downloadFile,
|
433 |
show_progress=True,
|
434 |
)
|
435 |
+
historyRefreshBtn.click(**refresh_history_args)
|
436 |
+
historyDeleteBtn.click(delete_chat_history, [current_model, historyFileSelectDropdown, user_name], [status_display, historyFileSelectDropdown], _js='''function showConfirmationDialog(a, b, c) {
|
437 |
+
var result = confirm("你真的要删除吗?");
|
438 |
+
if (result) {
|
439 |
+
return [a, b, c];
|
440 |
+
} else {
|
441 |
+
return [a, "CANCELED", c];
|
442 |
+
}
|
443 |
+
}''')
|
444 |
historyFileSelectDropdown.change(**load_history_from_file_args)
|
445 |
downloadFile.change(upload_chat_history, [current_model, downloadFile, user_name], [saveFileName, systemPromptTxt, chatbot])
|
446 |
|
modules/models/base_model.py
CHANGED
@@ -666,6 +666,8 @@ class BaseLLMModel:
|
|
666 |
return gr.update(), self.system_prompt, gr.update()
|
667 |
|
668 |
def delete_chat_history(self, filename, user_name):
|
|
|
|
|
669 |
if filename == "":
|
670 |
return i18n("你没有选择任何对话历史"), gr.update()
|
671 |
if not filename.endswith(".json"):
|
|
|
666 |
return gr.update(), self.system_prompt, gr.update()
|
667 |
|
668 |
def delete_chat_history(self, filename, user_name):
|
669 |
+
if filename == "CANCELED":
|
670 |
+
return gr.update(), gr.update()
|
671 |
if filename == "":
|
672 |
return i18n("你没有选择任何对话历史"), gr.update()
|
673 |
if not filename.endswith(".json"):
|