From 8d2159761f7ea695429128c5823e284e1243cb06 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Tue, 28 Jan 2025 10:06:21 -0800 Subject: [PATCH] refactor: Implement reasoning removal with regex in base_coder --- aider/coders/base_coder.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 887cc62f2..9c0dbc5d9 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -1884,9 +1884,11 @@ class Coder: new = new.rstrip() res = cur + new - # if self.main_model.remove_reasoning, then use that string. say it's "think" - # then use a regex to remove ".*" from the res - # the text may span many lines. ai! + + if self.main_model.remove_reasoning: + import re + pattern = f"<{self.main_model.remove_reasoning}>.*?" + res = re.sub(pattern, "", res, flags=re.DOTALL) return res