From 8f660aefe361d396847ebce03d86f0e501561c17 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Mon, 25 Aug 2025 18:50:16 -0700 Subject: [PATCH] Fix chat-instruct replies leaking the bot name sometimes --- modules/chat.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/chat.py b/modules/chat.py index 96d36ba5..a24a5be1 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -825,6 +825,12 @@ def chatbot_wrapper(text, state, regenerate=False, _continue=False, loading_mess # Extract the reply if state['mode'] in ['chat', 'chat-instruct']: + reply = reply.lstrip() + if reply.startswith(state['name2'] + ':'): + reply = reply[len(state['name2'] + ':'):] + elif reply.startswith(state['name1'] + ':'): + reply = reply[len(state['name1'] + ':'):] + visible_reply = re.sub("(||{{user}})", state['name1'], reply) else: visible_reply = reply