Tuchuanhuhuhu commited on
Commit
d86a58c
·
1 Parent(s): fd2b169

bugfix: history only shows the first character

Browse files
Files changed (1) hide show
  1. ChuanhuChatbot.py +14 -14
ChuanhuChatbot.py CHANGED
@@ -97,7 +97,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
97
  gr.HTML(get_html("func_nav.html"))
98
  # gr.HTML(get_html("footer.html").format(versions=versions_html()), elem_id="footer")
99
  # gr.Markdown(CHUANHU_DESCRIPTION, elem_id="chuanhu-author")
100
-
101
 
102
 
103
  with gr.Column(elem_id="chuanhu-area", scale=5):
@@ -114,12 +114,12 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
114
  gr.HTML(get_html("chatbot_header_btn.html"),elem_id="chatbot-header-btn-bar")
115
  with gr.Row():
116
  chatbot = gr.Chatbot(
117
- label="Chuanhu Chat",
118
- elem_id="chuanhu-chatbot",
119
- latex_delimiters=latex_delimiters_set,
120
- # height=700,
121
  show_label=False,
122
- avatar_images=[config.user_avatar, config.bot_avatar],
123
  show_share_button=False,
124
  )
125
  with gr.Row(elem_id="chatbot-footer"):
@@ -136,7 +136,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
136
  with gr.Column(min_width=225, scale=12):
137
  user_input = gr.Textbox(
138
  elem_id="user-input-tb",
139
- show_label=False,
140
  placeholder=i18n("在这里输入"),
141
  elem_classes="no-container",
142
  max_lines=5,
@@ -321,13 +321,13 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
321
  # label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False
322
  # )
323
  # with gr.Row():
324
-
325
  language_select_dropdown = gr.Dropdown(
326
  label=i18n("选择回复语言(针对搜索&索引功能)"),
327
  choices=REPLY_LANGUAGES,
328
  multiselect=False,
329
  value=REPLY_LANGUAGES[0],
330
- )
331
 
332
  with gr.Tab(label=i18n("高级")):
333
  gr.HTML(get_html("appearance_switcher.html").format(label=i18n("切换亮暗色主题")), elem_classes="insert-block", visible=False)
@@ -407,7 +407,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
407
  regenerate_i18n=i18n("重新生成"),
408
  deleteRound_i18n=i18n("删除这轮问答"),
409
  ))
410
- with gr.Box(elem_id="fake-gradio-components", visible=False):
411
  updateChuanhuBtn = gr.Button(visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
412
  changeSingleSessionBtn = gr.Button(visible=False, elem_classes="invisible-btn", elem_id="change-single-session-btn")
413
  changeOnlineSearchBtn = gr.Button(visible=False, elem_classes="invisible-btn", elem_id="change-online-search-btn")
@@ -424,8 +424,8 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
424
  current_model = get_model(model_name = MODELS[DEFAULT_MODEL], access_key = my_api_key)[0]
425
  current_model.set_user_identifier(user_name)
426
  chatbot = gr.Chatbot.update(label=MODELS[DEFAULT_MODEL])
427
- return user_info, user_name, current_model, toggle_like_btn_visibility(DEFAULT_MODEL), *current_model.auto_load(), get_history_dropdown(user_name), chatbot
428
- demo.load(create_greeting, inputs=None, outputs=[user_info, user_name, current_model, like_dislike_area, systemPromptTxt, chatbot, historyFileSelectDropdown, chatbot], api_name="load")
429
  chatgpt_predict_args = dict(
430
  fn=predict,
431
  inputs=[
@@ -632,13 +632,13 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
632
  )
633
  changeSingleSessionBtn.click(
634
  fn=lambda value: gr.Checkbox.update(value=value),
635
- inputs=[single_turn_checkbox],
636
  outputs=[single_turn_checkbox],
637
  _js='(a)=>{return bgChangeSingleSession(a);}'
638
  )
639
  changeOnlineSearchBtn.click(
640
  fn=lambda value: gr.Checkbox.update(value=value),
641
- inputs=[use_websearch_checkbox],
642
  outputs=[use_websearch_checkbox],
643
  _js='(a)=>{return bgChangeOnlineSearch(a);}'
644
  )
 
97
  gr.HTML(get_html("func_nav.html"))
98
  # gr.HTML(get_html("footer.html").format(versions=versions_html()), elem_id="footer")
99
  # gr.Markdown(CHUANHU_DESCRIPTION, elem_id="chuanhu-author")
100
+
101
 
102
 
103
  with gr.Column(elem_id="chuanhu-area", scale=5):
 
114
  gr.HTML(get_html("chatbot_header_btn.html"),elem_id="chatbot-header-btn-bar")
115
  with gr.Row():
116
  chatbot = gr.Chatbot(
117
+ label="Chuanhu Chat",
118
+ elem_id="chuanhu-chatbot",
119
+ latex_delimiters=latex_delimiters_set,
120
+ # height=700,
121
  show_label=False,
122
+ avatar_images=[config.user_avatar, config.bot_avatar],
123
  show_share_button=False,
124
  )
125
  with gr.Row(elem_id="chatbot-footer"):
 
136
  with gr.Column(min_width=225, scale=12):
137
  user_input = gr.Textbox(
138
  elem_id="user-input-tb",
139
+ show_label=False,
140
  placeholder=i18n("在这里输入"),
141
  elem_classes="no-container",
142
  max_lines=5,
 
321
  # label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False
322
  # )
323
  # with gr.Row():
324
+
325
  language_select_dropdown = gr.Dropdown(
326
  label=i18n("选择回复语言(针对搜索&索引功能)"),
327
  choices=REPLY_LANGUAGES,
328
  multiselect=False,
329
  value=REPLY_LANGUAGES[0],
330
+ )
331
 
332
  with gr.Tab(label=i18n("高级")):
333
  gr.HTML(get_html("appearance_switcher.html").format(label=i18n("切换亮暗色主题")), elem_classes="insert-block", visible=False)
 
407
  regenerate_i18n=i18n("重新生成"),
408
  deleteRound_i18n=i18n("删除这轮问答"),
409
  ))
410
+ with gr.Box(elem_id="fake-gradio-components", visible=False):
411
  updateChuanhuBtn = gr.Button(visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
412
  changeSingleSessionBtn = gr.Button(visible=False, elem_classes="invisible-btn", elem_id="change-single-session-btn")
413
  changeOnlineSearchBtn = gr.Button(visible=False, elem_classes="invisible-btn", elem_id="change-online-search-btn")
 
424
  current_model = get_model(model_name = MODELS[DEFAULT_MODEL], access_key = my_api_key)[0]
425
  current_model.set_user_identifier(user_name)
426
  chatbot = gr.Chatbot.update(label=MODELS[DEFAULT_MODEL])
427
+ return user_info, user_name, current_model, toggle_like_btn_visibility(DEFAULT_MODEL), *current_model.auto_load(), chatbot
428
+ demo.load(create_greeting, inputs=None, outputs=[user_info, user_name, current_model, like_dislike_area, systemPromptTxt, chatbot, chatbot], api_name="load")
429
  chatgpt_predict_args = dict(
430
  fn=predict,
431
  inputs=[
 
632
  )
633
  changeSingleSessionBtn.click(
634
  fn=lambda value: gr.Checkbox.update(value=value),
635
+ inputs=[single_turn_checkbox],
636
  outputs=[single_turn_checkbox],
637
  _js='(a)=>{return bgChangeSingleSession(a);}'
638
  )
639
  changeOnlineSearchBtn.click(
640
  fn=lambda value: gr.Checkbox.update(value=value),
641
+ inputs=[use_websearch_checkbox],
642
  outputs=[use_websearch_checkbox],
643
  _js='(a)=>{return bgChangeOnlineSearch(a);}'
644
  )