(text)
| 17 | |
| 18 | |
| 19 | def clean_assistant_output(text): |
| 20 | cleaned = str(text).strip() |
| 21 | cleaned = re.sub(r"^(jarvis\s*:\s*)+", "", cleaned, flags=re.IGNORECASE).strip() |
| 22 | cleaned = re.sub(r"^(jarvis[,.! ]+){2,}", "Jarvis ", cleaned, flags=re.IGNORECASE).strip() |
| 23 | return cleaned |
| 24 |