fix: deduplicate return code

This commit is contained in:
Manuel Schmid 2024-08-07 15:55:17 +02:00 committed by GitHub
parent 6ca62306b0
commit ea75b94e01
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: B5690EEEBB952194

View file

@ -1059,10 +1059,12 @@ def handle_start_new_chat_click(state):
convert_to_markdown.cache_clear()
if len(histories) == 0:
return [history, html, gr.update(choices=histories)]
if len(histories) > 0:
return_histories = gr.update(choices=histories, value=histories[0][1])
else:
return_histories = gr.update(choices=histories)
return [history, html, gr.update(choices=histories, value=histories[0][1])]
return [history, html, return_histories]
def handle_delete_chat_confirm_click(state):
@ -1113,17 +1115,15 @@ def handle_upload_chat_history(load_chat_history, state):
convert_to_markdown.cache_clear()
if len(histories) == 0:
return [
history,
html,
gr.update(choices=histories)
]
if len(histories) > 0:
return_histories = gr.update(choices=histories, value=histories[0][1])
else:
return_histories = gr.update(choices=histories)
return [
history,
html,
gr.update(choices=histories, value=histories[0][1])
return_histories
]
@ -1142,17 +1142,10 @@ def handle_character_menu_change(state):
convert_to_markdown.cache_clear()
if len(histories) == 0:
return [
history,
html,
name1,
name2,
picture,
greeting,
context,
gr.update(choices=histories)
]
if len(histories) > 0:
return_histories = gr.update(choices=histories, value=histories[0][1])
else:
return_histories = gr.update(choices=histories)
return [
history,
@ -1162,7 +1155,7 @@ def handle_character_menu_change(state):
picture,
greeting,
context,
gr.update(choices=histories, value=histories[0][1]),
return_histories,
]
@ -1173,21 +1166,17 @@ def handle_mode_change(state):
convert_to_markdown.cache_clear()
if len(histories) == 0:
return [
history,
html,
gr.update(visible=state['mode'] != 'instruct'),
gr.update(visible=state['mode'] == 'chat-instruct'),
gr.update(choices=histories)
]
if len(histories) > 0:
return_histories = gr.update(choices=histories, value=histories[0][1])
else:
return_histories = 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])
return_histories
]