From b657be73814329d9d8d81f1cec49fe7c738dc3ee Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Mon, 25 Aug 2025 18:22:08 -0700 Subject: [PATCH] Obtain stopping strings in chat mode --- modules/chat.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/chat.py b/modules/chat.py index d2513e07..8a9a5a1b 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -456,15 +456,17 @@ def get_stopping_strings(state): ] for text in texts: - text = text.strip() - if text.startswith("<") and ">" in text: - stopping_strings.append(text.split(">")[0] + ">") - elif text.startswith("[") and "]" in text: - stopping_strings.append(text.split("]")[0] + "]") - elif text.startswith("(") and ")" in text: - stopping_strings.append(text.split(")")[0] + ")") - elif text.startswith("{") and "}" in text: - stopping_strings.append(text.split("}")[0] + "}") + stripped_text = text.strip() + if stripped_text.startswith("<") and ">" in stripped_text: + stopping_strings.append(stripped_text.split(">")[0] + ">") + elif stripped_text.startswith("[") and "]" in stripped_text: + stopping_strings.append(stripped_text.split("]")[0] + "]") + elif stripped_text.startswith("(") and ")" in stripped_text: + stopping_strings.append(stripped_text.split(")")[0] + ")") + elif stripped_text.startswith("{") and "}" in stripped_text: + stopping_strings.append(stripped_text.split("}")[0] + "}") + elif ":" in text: + stopping_strings.append(text.split(":")[0] + ":") if 'stopping_strings' in state and isinstance(state['stopping_strings'], list): stopping_strings += state.pop('stopping_strings')