From 120f5662cf085d2cdaf387690a156d85ca7d131b Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Sun, 9 Apr 2023 20:37:31 -0300 Subject: [PATCH] Better handle spaces for Continue --- modules/chat.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/chat.py b/modules/chat.py index edd82216..6a1f7ad1 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -171,8 +171,9 @@ def chatbot_wrapper(text, generate_state, name1, name2, context, mode, end_of_tu shared.history['visible'].append(['', '']) if _continue: - shared.history['internal'][-1] = [text, f'{last_reply[0]} {reply}'] - shared.history['visible'][-1] = [visible_text, f'{last_reply[1]} {visible_reply}'] + sep = list(map(lambda x : ' ' if x[-1] != ' ' else '', last_reply)) + shared.history['internal'][-1] = [text, f'{last_reply[0]}{sep[0]}{reply}'] + shared.history['visible'][-1] = [visible_text, f'{last_reply[1]}{sep[1]}{visible_reply}'] else: shared.history['internal'][-1] = [text, reply] shared.history['visible'][-1] = [visible_text, visible_reply]