refactor: Simplify reasoning tag handling and remove debug print statements

This commit is contained in:
Paul Gauthier 2025-03-07 16:08:11 -08:00 committed by Paul Gauthier (aider)
parent 854428795b
commit d9551b3106

View file

@ -1394,9 +1394,10 @@ class Coder:
) )
self.multi_response_content = "" self.multi_response_content = ""
print() ###
print("=" * 20) # print()
dump(self.partial_response_content) # print("=" * 20)
# dump(self.partial_response_content)
self.io.tool_output() self.io.tool_output()
@ -1720,7 +1721,7 @@ class Coder:
return match.group(1) return match.group(1)
# Replace opening tag with proper spacing # Replace opening tag with proper spacing
text = re.sub(f"\\s*<{self.reasoning_tag_name}>\\s*", f"\n\n{REASONING_START}\n\n", text) text = re.sub(f"\\s*<{self.reasoning_tag_name}>\\s*", f"\n{REASONING_START}\n\n", text)
# Replace closing tag with proper spacing # Replace closing tag with proper spacing
text = re.sub(f"\\s*</{self.reasoning_tag_name}>\\s*", f"\n\n{REASONING_END}\n\n", text) text = re.sub(f"\\s*</{self.reasoning_tag_name}>\\s*", f"\n\n{REASONING_END}\n\n", text)
@ -1844,8 +1845,7 @@ class Coder:
self.live_incremental_response(False) self.live_incremental_response(False)
elif text: elif text:
# Apply reasoning tag formatting # Apply reasoning tag formatting
if self.got_reasoning_content: text = self.replace_reasoning_tags(text)
text = self.replace_reasoning_tags(text)
try: try:
sys.stdout.write(text) sys.stdout.write(text)
except UnicodeEncodeError: except UnicodeEncodeError:
@ -1863,8 +1863,7 @@ class Coder:
def live_incremental_response(self, final): def live_incremental_response(self, final):
show_resp = self.render_incremental_response(final) show_resp = self.render_incremental_response(final)
# Apply any reasoning tag formatting # Apply any reasoning tag formatting
if self.got_reasoning_content: show_resp = self.replace_reasoning_tags(show_resp)
show_resp = self.replace_reasoning_tags(show_resp)
self.mdstream.update(show_resp, final=final) self.mdstream.update(show_resp, final=final)
def render_incremental_response(self, final): def render_incremental_response(self, final):