Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
·
8beda5f
1
Parent(s):
eb4ccf0
chore: 重命名/导出时不再输出到File
Browse files- ChuanhuChatbot.py +6 -8
- modules/models/base_model.py +3 -2
ChuanhuChatbot.py
CHANGED
|
@@ -96,11 +96,10 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
| 96 |
# container=False,
|
| 97 |
)
|
| 98 |
with gr.Column(scale=1):
|
| 99 |
-
|
| 100 |
-
i18n("💾
|
| 101 |
exportMarkdownBtn = gr.Button(
|
| 102 |
-
i18n("📝
|
| 103 |
-
gr.Markdown(i18n("默认保存于history文件夹"))
|
| 104 |
with gr.Row():
|
| 105 |
with gr.Column():
|
| 106 |
downloadFile = gr.File(
|
|
@@ -641,18 +640,17 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
| 641 |
)
|
| 642 |
|
| 643 |
# S&L
|
| 644 |
-
|
| 645 |
save_chat_history,
|
| 646 |
[current_model, saveFileName, chatbot, user_name],
|
| 647 |
-
[
|
| 648 |
show_progress=True,
|
| 649 |
_js='(a,b,c,d)=>{return saveChatHistory(a,b,c,d);}'
|
| 650 |
)
|
| 651 |
-
saveHistoryBtn.click(get_history_list, [user_name], [historySelectList])
|
| 652 |
exportMarkdownBtn.click(
|
| 653 |
export_markdown,
|
| 654 |
[current_model, saveFileName, chatbot, user_name],
|
| 655 |
-
|
| 656 |
show_progress=True,
|
| 657 |
)
|
| 658 |
historyRefreshBtn.click(**refresh_history_args)
|
|
|
|
| 96 |
# container=False,
|
| 97 |
)
|
| 98 |
with gr.Column(scale=1):
|
| 99 |
+
renameHistoryBtn = gr.Button(
|
| 100 |
+
i18n("💾 Rename Chat"), elem_id="gr-history-save-btn")
|
| 101 |
exportMarkdownBtn = gr.Button(
|
| 102 |
+
i18n("📝 Export as Markdown"), elem_id="gr-markdown-export-btn")
|
|
|
|
| 103 |
with gr.Row():
|
| 104 |
with gr.Column():
|
| 105 |
downloadFile = gr.File(
|
|
|
|
| 640 |
)
|
| 641 |
|
| 642 |
# S&L
|
| 643 |
+
renameHistoryBtn.click(
|
| 644 |
save_chat_history,
|
| 645 |
[current_model, saveFileName, chatbot, user_name],
|
| 646 |
+
[historySelectList],
|
| 647 |
show_progress=True,
|
| 648 |
_js='(a,b,c,d)=>{return saveChatHistory(a,b,c,d);}'
|
| 649 |
)
|
|
|
|
| 650 |
exportMarkdownBtn.click(
|
| 651 |
export_markdown,
|
| 652 |
[current_model, saveFileName, chatbot, user_name],
|
| 653 |
+
[],
|
| 654 |
show_progress=True,
|
| 655 |
)
|
| 656 |
historyRefreshBtn.click(**refresh_history_args)
|
modules/models/base_model.py
CHANGED
|
@@ -668,7 +668,8 @@ class BaseLLMModel:
|
|
| 668 |
filename += ".json"
|
| 669 |
self.delete_chat_history(self.history_file_path, user_name)
|
| 670 |
self.history_file_path = filename
|
| 671 |
-
|
|
|
|
| 672 |
|
| 673 |
def auto_save(self, chatbot):
|
| 674 |
save_file(self.history_file_path, self.system_prompt,
|
|
@@ -679,7 +680,7 @@ class BaseLLMModel:
|
|
| 679 |
return
|
| 680 |
if not filename.endswith(".md"):
|
| 681 |
filename += ".md"
|
| 682 |
-
|
| 683 |
|
| 684 |
def load_chat_history(self, new_history_file_path=None, username=None):
|
| 685 |
logging.debug(f"{self.user_identifier} 加载对话历史中……")
|
|
|
|
| 668 |
filename += ".json"
|
| 669 |
self.delete_chat_history(self.history_file_path, user_name)
|
| 670 |
self.history_file_path = filename
|
| 671 |
+
save_file(filename, self.system_prompt, self.history, chatbot, user_name)
|
| 672 |
+
return init_history_list(user_name)
|
| 673 |
|
| 674 |
def auto_save(self, chatbot):
|
| 675 |
save_file(self.history_file_path, self.system_prompt,
|
|
|
|
| 680 |
return
|
| 681 |
if not filename.endswith(".md"):
|
| 682 |
filename += ".md"
|
| 683 |
+
save_file(filename, self.system_prompt, self.history, chatbot, user_name)
|
| 684 |
|
| 685 |
def load_chat_history(self, new_history_file_path=None, username=None):
|
| 686 |
logging.debug(f"{self.user_identifier} 加载对话历史中……")
|