Skip to content

Commit

Permalink
Do not set value for histories in chat when --multi-user is used (#6317)
Browse files Browse the repository at this point in the history
  • Loading branch information
mashb1t authored Sep 29, 2024
1 parent 055f3f5 commit 0f90a1b
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions modules/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,12 @@ def handle_start_new_chat_click(state):

convert_to_markdown.cache_clear()

return [history, html, gr.update(choices=histories, value=histories[0][1])]
if len(histories) > 0:
past_chats_update = gr.update(choices=histories, value=histories[0][1])
else:
past_chats_update = gr.update(choices=histories)

return [history, html, past_chats_update]


def handle_delete_chat_confirm_click(state):
Expand Down Expand Up @@ -1110,10 +1115,15 @@ def handle_upload_chat_history(load_chat_history, state):

convert_to_markdown.cache_clear()

if len(histories) > 0:
past_chats_update = gr.update(choices=histories, value=histories[0][1])
else:
past_chats_update = gr.update(choices=histories)

return [
history,
html,
gr.update(choices=histories, value=histories[0][1])
past_chats_update
]


Expand All @@ -1132,6 +1142,11 @@ def handle_character_menu_change(state):

convert_to_markdown.cache_clear()

if len(histories) > 0:
past_chats_update = gr.update(choices=histories, value=histories[0][1])
else:
past_chats_update = gr.update(choices=histories)

return [
history,
html,
Expand All @@ -1140,7 +1155,7 @@ def handle_character_menu_change(state):
picture,
greeting,
context,
gr.update(choices=histories, value=histories[0][1]),
past_chats_update,
]


Expand All @@ -1151,12 +1166,17 @@ def handle_mode_change(state):

convert_to_markdown.cache_clear()

if len(histories) > 0:
past_chats_update = gr.update(choices=histories, value=histories[0][1])
else:
past_chats_update = gr.update(choices=histories)

return [
history,
html,
gr.update(visible=state['mode'] != 'instruct'),
gr.update(visible=state['mode'] == 'chat-instruct'),
gr.update(choices=histories, value=histories[0][1])
past_chats_update
]


Expand Down

0 comments on commit 0f90a1b

Please sign in to comment.