Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
•
9869ac7
1
Parent(s):
6b8396d
bugfix: 现在未登陆时也可以正常加载历史记录了
Browse files- ChuanhuChatbot.py +7 -3
- modules/models/base_model.py +0 -4
- modules/utils.py +3 -0
ChuanhuChatbot.py
CHANGED
@@ -430,9 +430,13 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
430 |
user_info, user_name = gr.Markdown.update(value=f"", visible=False), ""
|
431 |
current_model = get_model(model_name = MODELS[DEFAULT_MODEL], access_key = my_api_key)[0]
|
432 |
current_model.set_user_identifier(user_name)
|
433 |
-
|
434 |
-
|
435 |
-
|
|
|
|
|
|
|
|
|
436 |
chatgpt_predict_args = dict(
|
437 |
fn=predict,
|
438 |
inputs=[
|
|
|
430 |
user_info, user_name = gr.Markdown.update(value=f"", visible=False), ""
|
431 |
current_model = get_model(model_name = MODELS[DEFAULT_MODEL], access_key = my_api_key)[0]
|
432 |
current_model.set_user_identifier(user_name)
|
433 |
+
if not hide_history_when_not_logged_in or user_name:
|
434 |
+
system_prompt, chatbot = current_model.auto_load()
|
435 |
+
else:
|
436 |
+
system_prompt = gr.update()
|
437 |
+
chatbot = gr.Chatbot.update(label=MODELS[DEFAULT_MODEL])
|
438 |
+
return user_info, user_name, current_model, toggle_like_btn_visibility(DEFAULT_MODEL), system_prompt, chatbot, init_history_list(user_name)
|
439 |
+
demo.load(create_greeting, inputs=None, outputs=[user_info, user_name, current_model, like_dislike_area, systemPromptTxt, chatbot, historyFileSelectDropdown], api_name="load")
|
440 |
chatgpt_predict_args = dict(
|
441 |
fn=predict,
|
442 |
inputs=[
|
modules/models/base_model.py
CHANGED
@@ -679,7 +679,6 @@ class BaseLLMModel:
|
|
679 |
|
680 |
def load_chat_history(self, new_history_file_path=None, username=None):
|
681 |
logging.debug(f"{self.user_identifier} 加载对话历史中……")
|
682 |
-
logging.info(f"filename: {self.history_file_path}")
|
683 |
if new_history_file_path is not None:
|
684 |
if type(new_history_file_path) != str:
|
685 |
self.history_file_path = new_history_file_path.name
|
@@ -735,9 +734,6 @@ class BaseLLMModel:
|
|
735 |
return i18n("对话历史")+filename+i18n("已经被删除啦"), gr.update(), gr.update()
|
736 |
|
737 |
def auto_load(self):
|
738 |
-
if self.user_identifier == "":
|
739 |
-
self.reset()
|
740 |
-
return self.system_prompt, gr.update()
|
741 |
self.history_file_path = get_history_filepath(self.user_identifier)
|
742 |
filename, system_prompt, chatbot = self.load_chat_history()
|
743 |
return system_prompt, chatbot
|
|
|
679 |
|
680 |
def load_chat_history(self, new_history_file_path=None, username=None):
|
681 |
logging.debug(f"{self.user_identifier} 加载对话历史中……")
|
|
|
682 |
if new_history_file_path is not None:
|
683 |
if type(new_history_file_path) != str:
|
684 |
self.history_file_path = new_history_file_path.name
|
|
|
734 |
return i18n("对话历史")+filename+i18n("已经被删除啦"), gr.update(), gr.update()
|
735 |
|
736 |
def auto_load(self):
|
|
|
|
|
|
|
737 |
self.history_file_path = get_history_filepath(self.user_identifier)
|
738 |
filename, system_prompt, chatbot = self.load_chat_history()
|
739 |
return system_prompt, chatbot
|
modules/utils.py
CHANGED
@@ -695,3 +695,6 @@ def get_file_hash(file_src=None, file_paths=None):
|
|
695 |
md5_hash.update(chunk)
|
696 |
|
697 |
return md5_hash.hexdigest()
|
|
|
|
|
|
|
|
695 |
md5_hash.update(chunk)
|
696 |
|
697 |
return md5_hash.hexdigest()
|
698 |
+
|
699 |
+
def myprint(**args):
|
700 |
+
print(args)
|