Spaces:
Sleeping
Sleeping
feat. 自动命名对话
Browse files- ChuanhuChatbot.py +4 -0
- modules/models/base_model.py +9 -0
- modules/utils.py +3 -0
ChuanhuChatbot.py
CHANGED
@@ -550,10 +550,14 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
550 |
chatgpt_predict_args).then(**end_outputing_args)
|
551 |
user_input.submit(**get_usage_args)
|
552 |
|
|
|
|
|
553 |
submitBtn.click(**transfer_input_args).then(**chatgpt_predict_args,
|
554 |
api_name="predict").then(**end_outputing_args)
|
555 |
submitBtn.click(**get_usage_args)
|
556 |
|
|
|
|
|
557 |
index_files.change(handle_file_upload, [current_model, index_files, chatbot, language_select_dropdown], [
|
558 |
index_files, chatbot, status_display])
|
559 |
summarize_btn.click(handle_summarize_index, [
|
|
|
550 |
chatgpt_predict_args).then(**end_outputing_args)
|
551 |
user_input.submit(**get_usage_args)
|
552 |
|
553 |
+
user_input.submit(auto_name_chat_history, [current_model, user_question, chatbot, user_name], [historySelectList], show_progress=False)
|
554 |
+
|
555 |
submitBtn.click(**transfer_input_args).then(**chatgpt_predict_args,
|
556 |
api_name="predict").then(**end_outputing_args)
|
557 |
submitBtn.click(**get_usage_args)
|
558 |
|
559 |
+
submitBtn.click(auto_name_chat_history, [current_model, user_question, chatbot, user_name], [historySelectList], show_progress=False)
|
560 |
+
|
561 |
index_files.change(handle_file_upload, [current_model, index_files, chatbot, language_select_dropdown], [
|
562 |
index_files, chatbot, status_display])
|
563 |
summarize_btn.click(handle_summarize_index, [
|
modules/models/base_model.py
CHANGED
@@ -671,6 +671,15 @@ class BaseLLMModel:
|
|
671 |
self.history_file_path = filename
|
672 |
save_file(filename, self.system_prompt, self.history, chatbot, user_name)
|
673 |
return init_history_list(user_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
674 |
|
675 |
def auto_save(self, chatbot):
|
676 |
save_file(self.history_file_path, self.system_prompt,
|
|
|
671 |
self.history_file_path = filename
|
672 |
save_file(filename, self.system_prompt, self.history, chatbot, user_name)
|
673 |
return init_history_list(user_name)
|
674 |
+
|
675 |
+
def auto_name_chat_history(self, user_question, chatbot, user_name):
|
676 |
+
if chatbot == []:
|
677 |
+
filename = user_question[:12] + ".json"
|
678 |
+
return self.rename_chat_history(filename, chatbot, user_name)
|
679 |
+
else:
|
680 |
+
return gr.update()
|
681 |
+
|
682 |
+
|
683 |
|
684 |
def auto_save(self, chatbot):
|
685 |
save_file(self.history_file_path, self.system_prompt,
|
modules/utils.py
CHANGED
@@ -71,6 +71,9 @@ def set_system_prompt(current_model, *args):
|
|
71 |
def rename_chat_history(current_model, *args):
|
72 |
return current_model.rename_chat_history(*args)
|
73 |
|
|
|
|
|
|
|
74 |
def export_markdown(current_model, *args):
|
75 |
return current_model.export_markdown(*args)
|
76 |
|
|
|
71 |
def rename_chat_history(current_model, *args):
|
72 |
return current_model.rename_chat_history(*args)
|
73 |
|
74 |
+
def auto_name_chat_history(current_model, *args):
|
75 |
+
return current_model.auto_name_chat_history(*args)
|
76 |
+
|
77 |
def export_markdown(current_model, *args):
|
78 |
return current_model.export_markdown(*args)
|
79 |
|