Obtain stopping strings in chat mode

This commit is contained in:
oobabooga 2025-08-25 18:22:08 -07:00
parent ded6c41cf8
commit b657be7381

View file

@ -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')