Tuchuanhuhuhu commited on
Commit
bef1526
1 Parent(s): e5adc30

bugfix: 修复正则搜索时不正确表达式导致搜索出错的问题

Browse files
Files changed (2) hide show
  1. ChuanhuChatbot.py +1 -1
  2. modules/utils.py +5 -2
ChuanhuChatbot.py CHANGED
@@ -62,7 +62,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
62
  with gr.Row(elem_id="chuanhu-history"):
63
  with gr.Column():
64
  historySearchTextbox = gr.Textbox(show_label=False, placeholder=i18n(
65
- "搜索..."), lines=1, elem_id="history-search-tb")
66
  with gr.Row():
67
  with gr.Column(scale=6, elem_id="history-select-wrap"):
68
  historySelectList = gr.Radio(
 
62
  with gr.Row(elem_id="chuanhu-history"):
63
  with gr.Column():
64
  historySearchTextbox = gr.Textbox(show_label=False, placeholder=i18n(
65
+ "搜索(支持正则)..."), lines=1, elem_id="history-search-tb")
66
  with gr.Row():
67
  with gr.Column(scale=6, elem_id="history-select-wrap"):
68
  historySelectList = gr.Radio(
modules/utils.py CHANGED
@@ -410,8 +410,11 @@ def init_history_list(user_name=""):
410
 
411
  def filter_history(user_name, keyword):
412
  history_names = get_history_names(user_name)
413
- history_names = [name for name in history_names if re.search(keyword, name)]
414
- return gr.update(choices=history_names)
 
 
 
415
 
416
  def load_template(filename, mode=0):
417
  logging.debug(f"加载模板文件{filename},模式为{mode}(0为返回字典和下拉菜单,1为返回下拉菜单,2为返回字典)")
 
410
 
411
  def filter_history(user_name, keyword):
412
  history_names = get_history_names(user_name)
413
+ try:
414
+ history_names = [name for name in history_names if re.search(keyword, name)]
415
+ return gr.update(choices=history_names)
416
+ except:
417
+ return gr.update(choices=history_names)
418
 
419
  def load_template(filename, mode=0):
420
  logging.debug(f"加载模板文件{filename},模式为{mode}(0为返回字典和下拉菜单,1为返回下拉菜单,2为返回字典)")