mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-05 20:25:01 +00:00
refactor: Simplify reasoning tag handling and remove unused function
This commit is contained in:
parent
8fb235c3f5
commit
de4693cdf3
2 changed files with 15 additions and 26 deletions
|
@ -1743,11 +1743,13 @@ class Coder:
|
|||
show_resp = self.render_incremental_response(True)
|
||||
|
||||
if reasoning_content:
|
||||
formatted_reasoning = (
|
||||
format_reasoning_content(reasoning_content, self.reasoning_tag_name) + "\n\n"
|
||||
formatted_reasoning = format_reasoning_content(
|
||||
reasoning_content, self.reasoning_tag_name
|
||||
)
|
||||
show_resp = formatted_reasoning + show_resp
|
||||
|
||||
show_resp = replace_reasoning_tags(show_resp, self.reasoning_tag_name)
|
||||
|
||||
self.io.assistant_output(show_resp, pretty=self.show_pretty())
|
||||
|
||||
if (
|
||||
|
|
|
@ -2,12 +2,15 @@
|
|||
|
||||
import re
|
||||
|
||||
from aider.dump import dump # noqa
|
||||
|
||||
# Standard tag identifier
|
||||
REASONING_TAG = "thinking-content-" + "7bbeb8e1441453ad999a0bbba8a46d4b"
|
||||
# Output formatting
|
||||
REASONING_START = "> Thinking ..."
|
||||
REASONING_END = "> ... done thinking.\n\n------"
|
||||
|
||||
|
||||
def replace_reasoning_tags(text, tag_name):
|
||||
"""
|
||||
Replace opening and closing reasoning tags with standard formatting.
|
||||
|
@ -29,11 +32,9 @@ def replace_reasoning_tags(text, tag_name):
|
|||
# Replace closing tag with proper spacing
|
||||
text = re.sub(f"\\s*</{tag_name}>\\s*", f"\n\n{REASONING_END}\n\n", text)
|
||||
|
||||
# Clean up any excessive newlines (more than 2 consecutive)
|
||||
text = re.sub(r"\n{3,}", "\n\n", text)
|
||||
|
||||
return text
|
||||
|
||||
|
||||
def format_reasoning_content(reasoning_content, tag_name):
|
||||
"""
|
||||
Format reasoning content with appropriate tags.
|
||||
|
@ -49,18 +50,4 @@ def format_reasoning_content(reasoning_content, tag_name):
|
|||
return ""
|
||||
|
||||
formatted = f"<{tag_name}>\n\n{reasoning_content}\n\n</{tag_name}>"
|
||||
return replace_reasoning_tags(formatted, tag_name)
|
||||
|
||||
def detect_reasoning_tag(text, tag_name):
|
||||
"""
|
||||
Detect if text contains reasoning tags.
|
||||
|
||||
Args:
|
||||
text (str): The text to check
|
||||
tag_name (str): The tag name to look for
|
||||
|
||||
Returns:
|
||||
bool: True if text contains reasoning tags
|
||||
"""
|
||||
opening_pattern = f"<{tag_name}>"
|
||||
return opening_pattern in text
|
||||
return formatted
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue