Tuchuanhuhuhu commited on
Commit
20c2fc5
1 Parent(s): 10ba661

bugfix: 解决刷新列表时列表中只有第一个字的问题

Browse files
ChuanhuChatbot.py CHANGED
@@ -476,7 +476,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
476
  )
477
 
478
  refresh_history_args = dict(
479
- fn=get_history_dropdown, inputs=[user_name], outputs=[historyFileSelectDropdown]
480
  )
481
 
482
 
@@ -575,7 +575,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
575
  downloadFile,
576
  show_progress=True,
577
  )
578
- saveHistoryBtn.click(get_history_dropdown, [user_name], [historyFileSelectDropdown])
579
  exportMarkdownBtn.click(
580
  export_markdown,
581
  [current_model, saveFileName, chatbot, user_name],
@@ -584,7 +584,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
584
  )
585
  historyRefreshBtn.click(**refresh_history_args)
586
  historyDeleteBtn.click(delete_chat_history, [current_model, historyFileSelectDropdown, user_name], [status_display, historyFileSelectDropdown, chatbot], _js='(a,b,c)=>{return showConfirmationDialog(a, b, c);}')
587
- historyFileSelectDropdown.change(**load_history_from_file_args)
588
  downloadFile.change(upload_chat_history, [current_model, downloadFile, user_name], [saveFileName, systemPromptTxt, chatbot])
589
  historyDownloadBtn.click(None, [user_name, historyFileSelectDropdown], None, _js='(a,b)=>{return downloadHistory(a,b);}')
590
 
 
476
  )
477
 
478
  refresh_history_args = dict(
479
+ fn=get_history_list, inputs=[user_name], outputs=[historyFileSelectDropdown]
480
  )
481
 
482
 
 
575
  downloadFile,
576
  show_progress=True,
577
  )
578
+ saveHistoryBtn.click(get_history_list, [user_name], [historyFileSelectDropdown])
579
  exportMarkdownBtn.click(
580
  export_markdown,
581
  [current_model, saveFileName, chatbot, user_name],
 
584
  )
585
  historyRefreshBtn.click(**refresh_history_args)
586
  historyDeleteBtn.click(delete_chat_history, [current_model, historyFileSelectDropdown, user_name], [status_display, historyFileSelectDropdown, chatbot], _js='(a,b,c)=>{return showConfirmationDialog(a, b, c);}')
587
+ historyFileSelectDropdown.input(**load_history_from_file_args)
588
  downloadFile.change(upload_chat_history, [current_model, downloadFile, user_name], [saveFileName, systemPromptTxt, chatbot])
589
  historyDownloadBtn.click(None, [user_name, historyFileSelectDropdown], None, _js='(a,b)=>{return downloadHistory(a,b);}')
590
 
modules/models/base_model.py CHANGED
@@ -724,7 +724,7 @@ class BaseLLMModel:
724
  history_file_path = filename
725
  try:
726
  os.remove(history_file_path)
727
- return i18n("删除对话历史成功"), get_history_dropdown(user_name), []
728
  except:
729
  logging.info(f"删除对话历史失败 {history_file_path}")
730
  return i18n("对话历史")+filename+i18n("已经被删除啦"), gr.update(), gr.update()
 
724
  history_file_path = filename
725
  try:
726
  os.remove(history_file_path)
727
+ return i18n("删除对话历史成功"), get_history_list(user_name), []
728
  except:
729
  logging.info(f"删除对话历史失败 {history_file_path}")
730
  return i18n("对话历史")+filename+i18n("已经被删除啦"), gr.update(), gr.update()
modules/utils.py CHANGED
@@ -395,9 +395,9 @@ def get_history_names(user_name=""):
395
  history_files = get_file_names_by_last_modified_time(os.path.join(HISTORY_DIR, user_name))
396
  return history_files
397
 
398
- def get_history_dropdown(user_name=""):
399
  history_names = get_history_names(user_name)
400
- return gr.Dropdown.update(choices=history_names)
401
 
402
 
403
  def load_template(filename, mode=0):
 
395
  history_files = get_file_names_by_last_modified_time(os.path.join(HISTORY_DIR, user_name))
396
  return history_files
397
 
398
+ def get_history_list(user_name=""):
399
  history_names = get_history_names(user_name)
400
+ return gr.Radio.update(choices=history_names)
401
 
402
 
403
  def load_template(filename, mode=0):