Do not set value for histories in chat when --multi-user is used (#6317)

This commit is contained in:
Manuel Schmid 2024-09-29 06:08:55 +02:00 committed by GitHub
parent 055f3f5632
commit 0f90a1b50f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1059,7 +1059,12 @@ def handle_start_new_chat_click(state):
convert_to_markdown.cache_clear() 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): def handle_delete_chat_confirm_click(state):
@ -1110,10 +1115,15 @@ def handle_upload_chat_history(load_chat_history, state):
convert_to_markdown.cache_clear() 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 [ return [
history, history,
html, html,
gr.update(choices=histories, value=histories[0][1]) past_chats_update
] ]
@ -1132,6 +1142,11 @@ def handle_character_menu_change(state):
convert_to_markdown.cache_clear() 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 [ return [
history, history,
html, html,
@ -1140,7 +1155,7 @@ def handle_character_menu_change(state):
picture, picture,
greeting, greeting,
context, context,
gr.update(choices=histories, value=histories[0][1]), past_chats_update,
] ]
@ -1151,12 +1166,17 @@ def handle_mode_change(state):
convert_to_markdown.cache_clear() 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 [ return [
history, history,
html, html,
gr.update(visible=state['mode'] != 'instruct'), gr.update(visible=state['mode'] != 'instruct'),
gr.update(visible=state['mode'] == 'chat-instruct'), gr.update(visible=state['mode'] == 'chat-instruct'),
gr.update(choices=histories, value=histories[0][1]) past_chats_update
] ]