Update only the last message during streaming + add back dynamic UI update speed (#7038)

This commit is contained in:
oobabooga 2025-06-02 09:50:17 -03:00 committed by GitHub
parent 45c9ae312c
commit bb409c926e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 181 additions and 156 deletions

View file

@ -825,7 +825,9 @@ def generate_chat_reply_wrapper(text, state, regenerate=False, _continue=False):
last_save_time = time.monotonic()
save_interval = 8
for i, history in enumerate(generate_chat_reply(text, state, regenerate, _continue, loading_message=True, for_ui=True)):
yield chat_html_wrapper(history, state['name1'], state['name2'], state['mode'], state['chat_style'], state['character_menu']), history
yield chat_html_wrapper(history, state['name1'], state['name2'], state['mode'], state['chat_style'], state['character_menu'], last_message_only=(i > 0)), history
if i == 0:
time.sleep(0.125) # We need this to make sure the first update goes through
current_time = time.monotonic()
# Save on first iteration or if save_interval seconds have passed