mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
refactor: Modify reasoning content removal method to update partial_response_content directly
This commit is contained in:
parent
cddc67ad69
commit
08401aff26
2 changed files with 10 additions and 10 deletions
|
@ -1381,11 +1381,7 @@ class Coder:
|
||||||
self.mdstream = None
|
self.mdstream = None
|
||||||
|
|
||||||
self.partial_response_content = self.get_multi_response_content_in_progress(True)
|
self.partial_response_content = self.get_multi_response_content_in_progress(True)
|
||||||
|
self.remove_reasoning_content()
|
||||||
self.partial_response_content = self.remove_reasoning_content(
|
|
||||||
self.partial_response_content,
|
|
||||||
self.reasoning_tag_name,
|
|
||||||
)
|
|
||||||
self.multi_response_content = ""
|
self.multi_response_content = ""
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -1833,9 +1829,13 @@ class Coder:
|
||||||
def render_incremental_response(self, final):
|
def render_incremental_response(self, final):
|
||||||
return self.get_multi_response_content_in_progress()
|
return self.get_multi_response_content_in_progress()
|
||||||
|
|
||||||
def remove_reasoning_content(self, content, reasoning_tag_name):
|
def remove_reasoning_content(self):
|
||||||
"""Remove reasoning content from the model's response."""
|
"""Remove reasoning content from the model's response."""
|
||||||
return self.main_model.remove_reasoning_content(content, reasoning_tag_name)
|
|
||||||
|
self.partial_response_content = self.main_model.remove_reasoning_content(
|
||||||
|
self.partial_response_content,
|
||||||
|
self.reasoning_tag_name,
|
||||||
|
)
|
||||||
|
|
||||||
def calculate_and_show_tokens_and_cost(self, messages, completion=None):
|
def calculate_and_show_tokens_and_cost(self, messages, completion=None):
|
||||||
prompt_tokens = 0
|
prompt_tokens = 0
|
||||||
|
|
|
@ -59,6 +59,7 @@ class TestReasoning(unittest.TestCase):
|
||||||
self.assertIn(main_content, output)
|
self.assertIn(main_content, output)
|
||||||
|
|
||||||
# Verify that partial_response_content only contains the main content
|
# Verify that partial_response_content only contains the main content
|
||||||
|
coder.remove_reasoning_content()
|
||||||
self.assertEqual(coder.partial_response_content.strip(), main_content.strip())
|
self.assertEqual(coder.partial_response_content.strip(), main_content.strip())
|
||||||
|
|
||||||
# Ensure proper order: reasoning first, then main content
|
# Ensure proper order: reasoning first, then main content
|
||||||
|
@ -168,12 +169,10 @@ class TestReasoning(unittest.TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Verify that partial_response_content only contains the main content
|
# Verify that partial_response_content only contains the main content
|
||||||
|
coder.remove_reasoning_content()
|
||||||
expected_content = "Final answer after reasoning"
|
expected_content = "Final answer after reasoning"
|
||||||
self.assertEqual(coder.partial_response_content.strip(), expected_content)
|
self.assertEqual(coder.partial_response_content.strip(), expected_content)
|
||||||
|
|
||||||
# Verify that partial_response_content only contains the main content
|
|
||||||
self.assertEqual(coder.partial_response_content.strip(), "Final answer after reasoning")
|
|
||||||
|
|
||||||
def test_send_with_think_tags(self):
|
def test_send_with_think_tags(self):
|
||||||
"""Test that <think> tags are properly processed and formatted."""
|
"""Test that <think> tags are properly processed and formatted."""
|
||||||
# Setup IO with no pretty
|
# Setup IO with no pretty
|
||||||
|
@ -240,6 +239,7 @@ class TestReasoning(unittest.TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Verify that partial_response_content only contains the main content
|
# Verify that partial_response_content only contains the main content
|
||||||
|
coder.remove_reasoning_content()
|
||||||
self.assertEqual(coder.partial_response_content.strip(), main_content.strip())
|
self.assertEqual(coder.partial_response_content.strip(), main_content.strip())
|
||||||
|
|
||||||
def test_send_with_think_tags_stream(self):
|
def test_send_with_think_tags_stream(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue